You are here

class CommerceCustomerUITest in Commerce Core 7

Functional tests for the commerce customer UI module.

Hierarchy

Expanded class hierarchy of CommerceCustomerUITest

File

modules/customer/tests/commerce_customer_ui.test, line 11
Commerce customer profile tests.

View source
class CommerceCustomerUITest extends CommerceBaseTestCase {

  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => 'Customer user interface',
      'description' => 'Test creating, editing, deleting cusomer profiles and how they interact with other components, like orders.',
      'group' => 'Drupal Commerce',
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    $modules = parent::setUpHelper('all');
    parent::setUp($modules);

    // User creation for different operations.
    $this->store_admin = $this
      ->createStoreAdmin();
    $this->store_customer = $this
      ->createStoreCustomer();

    // Set the default country to US.
    variable_set('site_default_country', 'US');
  }

  /**
   * Load a customer profile basing in field conditions.
   */
  protected function loadCustomerProfile($conditions) {
    $query = db_select('commerce_customer_profile', 'cp');
    $query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type', 'commerce_customer_profile', '=');
    foreach ($conditions as $condition) {
      $operation = !empty($condition['operation']) ? $condition['operation'] : '=';
      $query
        ->fieldCondition($condition['field'], $condition['column'], $condition['value'], $operation);
    }
    $results = $query
      ->execute();
    return $results['commerce_customer_profile'];
  }

  /**
   * Access to the customer profiles listing.
   */
  public function testCommerceCustomerUIAccessCustomerProfilesListing() {

    // Login with customer.
    $this
      ->drupalLogin($this->store_customer);

    // Check the access to the profiles listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertResponse(403, t('The store customer has no access to the administration listing of customer profiles'));

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the access to the profiles listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertResponse(200, t('The store customer has access to the administration listing of customer profiles'));

    // Check the message of no profiles available.
    $this
      ->assertText(t('No customer profiles have been created yet.'), t('\'No customer profiles have been created yet\' message is displayed'));

    // Check the add customer profile link.
    $this
      ->assertRaw(l('Add a customer profile', 'admin/commerce/customer-profiles/add'), t('\'Add a customer profile\' link is present in the page'));
  }

  /**
   * Access to the customer profile types listing.
   */
  public function testCommerceCustomerUIAccessCustomerProfileTypesListing() {

    // Login with customer.
    $this
      ->drupalLogin($this->store_customer);

    // Check the access to the profile types listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles/types');
    $this
      ->assertResponse(403, t('The store customer has no access to the administration listing of customer profile types'));

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the access to the profile types listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles/types');
    $this
      ->assertResponse(200, t('The store customer has access to the administration listing of customer profile types'));

    // Check if all the profiles defined by default are there.
    $types = commerce_customer_profile_types();
    foreach ($types as $type) {
      $this
        ->assertText($type['name'], t('!type customer profile type is found in the listing', array(
        '!type' => $type['name'],
      )));
    }
  }

  /**
   * Add a customer profile.
   */
  public function testCommerceCustomerUIAddCustomerProfile() {

    // Login with customer.
    $this
      ->drupalLogin($this->store_customer);

    // Check the access to the profile add page.
    $this
      ->drupalGet('admin/commerce/customer-profiles/add');

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the access to the profile add page.
    $this
      ->drupalGet('admin/commerce/customer-profiles/add');

    // As The billing information is the only profile shipped by default at
    // the moment, the destination url is the billing information creation
    // form.
    $this
      ->assertTrue($this->url = url('admin/commerce/customer-profiles/add/billing', array(
      'absolute => TRUE',
    )));

    // Get the default values for the address.
    $field = field_info_field('commerce_customer_address');
    $instance = field_info_instance('commerce_customer_profile', 'commerce_customer_address', 'billing');
    $address = addressfield_default_values($field, $instance);

    // Check the integrity of the add form.
    $this
      ->pass(t('Test the integrity of the add customer profile form:'));
    $billing_country = $this
      ->xpath("//select[starts-with(@name, 'commerce_customer_address')]");
    $this
      ->drupalPostAJAX(NULL, array(
      (string) $billing_country[0]['name'] => $address['country'],
    ), (string) $billing_country[0]['name']);
    $this
      ->assertFieldByXPath("//select[starts-with(@id, 'edit-commerce-customer-address-und-0-country')]", $address['country'], t('Country field exists and it has the default country selected'));
    $this
      ->assertFieldByXPath("//input[starts-with(@id, 'edit-commerce-customer-address-und-0-name-line')]", NULL, t('Field !field exists in the customer profile form', array(
      '!field' => 'Name line',
    )));

    // Also check for the buttons and cancel link.
    $this
      ->assertFieldById('edit-submit', t('Save profile'), t('\'Save profile\' button is present'));
    $this
      ->assertFieldById('edit-save-continue', t('Save and add another'), t('\'Save an add another\' button is present'));
    $this
      ->assertRaw(l(t('Cancel'), 'admin/commerce/customer-profiles'), t('Cancel link is present'));

    // Generate random information, as city, postal code, etc.
    $address_info = $this
      ->generateAddressInformation();

    // Fill the profile information and Save.
    $info = array(
      'commerce_customer_address[und][0][name_line]' => $address_info['name_line'],
      'commerce_customer_address[und][0][thoroughfare]' => $address_info['thoroughfare'],
      'commerce_customer_address[und][0][locality]' => $address_info['locality'],
      'commerce_customer_address[und][0][administrative_area]' => $address_info['administrative_area'],
      'commerce_customer_address[und][0][postal_code]' => $address_info['postal_code'],
    );
    $this
      ->drupalPost(NULL, $info, t('Save profile'));

    // Check in database if the profile got created.
    $conditions = array();
    foreach ($address_info as $id => $element) {
      $conditions[] = array(
        'field' => 'commerce_customer_address',
        'column' => $id,
        'value' => $element,
      );
    }
    $profile = $this
      ->loadCustomerProfile($conditions);
    $this
      ->assertFalse(empty($profile), t('Profile has been created in database'));

    // Check the landing url and if the profile is in the listing.
    $this
      ->assertTrue($this->url == url('admin/commerce/customer-profiles', array(
      'absolute' => TRUE,
    )), t('Landing page after save the profile is the profile listing page'));
    $this
      ->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile'));
    $this
      ->assertText($address_info['name_line'], t('Profile name line value: !value is present in the customer profile listing', array(
      '!value' => $address_info['name_line'],
    )));
  }

  /**
   * Save and add another customer profile.
   */
  public function testCommerceCustomerUIAddCustomerProfileSaveAndAddAnother() {

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the access to the profile add page.
    $this
      ->drupalGet('admin/commerce/customer-profiles/add');

    // Fill the profile information and click on Save and add another.
    $billing_country = $this
      ->xpath("//select[starts-with(@name, 'commerce_customer_address')]");
    $this
      ->drupalPostAJAX(NULL, array(
      (string) $billing_country[0]['name'] => variable_get('site_default_country', 'US'),
    ), (string) $billing_country[0]['name']);

    // Generate random information, as city, postal code, etc.
    $address_info = $this
      ->generateAddressInformation();

    // Fill the profile information and Save.
    $info = array(
      'commerce_customer_address[und][0][name_line]' => $address_info['name_line'],
      'commerce_customer_address[und][0][thoroughfare]' => $address_info['thoroughfare'],
      'commerce_customer_address[und][0][locality]' => $address_info['locality'],
      'commerce_customer_address[und][0][administrative_area]' => $address_info['administrative_area'],
      'commerce_customer_address[und][0][postal_code]' => $address_info['postal_code'],
    );
    $this
      ->drupalPost(NULL, $info, t('Save and add another'));

    // Check the landing url and if the profile got created.
    $this
      ->assertTrue($this->url == url('admin/commerce/customer-profiles/add/billing', array(
      'absolute' => TRUE,
    )), t('Landing page after save and add another for profiles is the profile creation page'));
    $this
      ->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile'));
    $this
      ->assertFieldById('edit-commerce-customer-address-und-0-name-line', '', t('\'Name line\' field is present and empty'));
    $conditions = array();
    foreach ($address_info as $id => $element) {
      $conditions[] = array(
        'field' => 'commerce_customer_address',
        'column' => $id,
        'value' => $element,
      );
    }
    $profile = $this
      ->loadCustomerProfile($conditions);
    $this
      ->assertFalse(empty($profile), t('Profile has been created in database'));
  }

  /**
   * Add extra fields to a profile type.
   */
  public function testCommerceCustomerUIProfileWithExtraFields() {

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Access to the profile billing type manage fields.
    $this
      ->drupalGet('admin/commerce/customer-profiles/types/billing/fields');
    $this
      ->assertResponse(200, t('Store admin user is able to access the customer profile type manage fields screen'));

    // Create an extra field for the profile.
    $edit = array(
      'fields[_add_new_field][label]' => $this
        ->randomName(),
      'fields[_add_new_field][field_name]' => strtolower($this
        ->randomName()),
      'fields[_add_new_field][type]' => 'text',
      'fields[_add_new_field][widget_type]' => 'text_textfield',
    );
    $this
      ->drupalPost(NULL, $edit, t('Save'));
    $this
      ->drupalPost(NULL, array(), t('Save field settings'));
    $this
      ->drupalPost(NULL, array(), t('Save settings'));

    // Add a new profile, check that the field is there.
    $this
      ->drupalGet('admin/commerce/customer-profiles/add');

    // Assert that the field exists in the profile add form.
    $address_info = $this
      ->generateAddressInformation();

    // Fill the profile information and Save.
    $info = array(
      'commerce_customer_address[und][0][name_line]' => $address_info['name_line'],
      'commerce_customer_address[und][0][thoroughfare]' => $address_info['thoroughfare'],
      'commerce_customer_address[und][0][locality]' => $address_info['locality'],
      'commerce_customer_address[und][0][administrative_area]' => $address_info['administrative_area'],
      'commerce_customer_address[und][0][postal_code]' => $address_info['postal_code'],
    );

    // Also add the new field value.
    $field_value = $this
      ->randomName();
    $info['field_' . $edit['fields[_add_new_field][field_name]'] . '[und][0][value]'] = $field_value;
    $this
      ->drupalPost(NULL, $info, t('Save profile'));

    // Check that the profile got created and if the field is filled.
    $this
      ->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile'));

    // Check also in database.
    foreach ($address_info as $id => $element) {
      $conditions[] = array(
        'field' => 'commerce_customer_address',
        'column' => $id,
        'value' => $element,
      );
    }

    // Load the profile and check if the field is filled.
    $profiles = $this
      ->loadCustomerProfile($conditions);
    $profile = commerce_customer_profile_load(reset($profiles)->profile_id);
    $this
      ->assertTrue($profile->{'field_' . $edit['fields[_add_new_field][field_name]']}[LANGUAGE_NONE][0]['value'] == $field_value, t('The extra field !field created for the customer profile exists and it has the correct value: !value', array(
      '!field' => $edit['fields[_add_new_field][field_name]'],
      '!value' => $field_value,
    )));
  }

  /**
   * Edit a previously existing customer profile.
   */
  public function testCommerceCustomerUIEditCustomerProfile() {

    // Create a new customer profile.
    $profile = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Edit the customer profile.
    $this
      ->drupalGet('admin/commerce/customer-profiles/' . $profile->profile_id . '/edit');
    $address = $profile->commerce_customer_address[LANGUAGE_NONE][0];

    // Check the integrity of the edit form.
    $this
      ->pass(t('Test the integrity of the edit customer profile form:'));
    $this
      ->assertFieldById('edit-commerce-customer-address-und-0-country', $address['country'], t('Country field exists and it has the default country selected'));
    $this
      ->assertFieldById('edit-commerce-customer-address-und-0-name-line', $address['name_line'], t('Field !field exists in the customer profile form and has the correct value !value', array(
      '!field' => 'Name line',
      '!value' => $address['name_line'],
    )));

    // Also check for the buttons and cancel link.
    $this
      ->assertFieldById('edit-submit', t('Save profile'), t('\'Save profile\' button is present'));
    $this
      ->assertRaw(l(t('Cancel'), 'admin/commerce/customer-profiles'), t('Cancel link is present'));

    // Change some fields and save.
    $edit = array(
      'commerce_customer_address[und][0][name_line]' => 'Example Name line',
      'commerce_customer_address[und][0][locality]' => 'Example Locality',
      'name' => '',
    );
    $this
      ->drupalPost(NULL, $edit, t('Save profile'));

    // Assert fields after saving the profile.
    $this
      ->pass(t('Assert the field values after saving the profile form:'));
    $this
      ->assertTrue($this->url == url('admin/commerce/customer-profiles/' . $profile->profile_id . '/edit', array(
      'absolute' => TRUE,
    )), t('Landing page after save the profile is the profile edit page'));
    $this
      ->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile'));
    $this
      ->assertFieldById('edit-commerce-customer-address-und-0-name-line', $edit['commerce_customer_address[und][0][name_line]'], t('Field !field exists in the customer profile form and has the correct value !value', array(
      '!field' => 'Name line',
      '!value' => $edit['commerce_customer_address[und][0][name_line]'],
    )));
    $this
      ->assertFieldById('edit-commerce-customer-address-und-0-locality', $edit['commerce_customer_address[und][0][locality]'], t('Field !field exists in the customer profile form and has the correct value !value', array(
      '!field' => 'Locality',
      '!value' => $edit['commerce_customer_address[und][0][locality]'],
    )));
    $this
      ->assertFieldByName('name', NULL, t('Name field is present and empty'));

    // Check at database level.
    $profiles = commerce_customer_profile_load_multiple(array(
      $profile->profile_id,
    ), array(), TRUE);
    $profile = reset($profiles);
    $this
      ->assertTrue($profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] == $edit['commerce_customer_address[und][0][name_line]'], t('\'Name line\' field has been correctly modified in the customer profile'));
    $this
      ->assertTrue($profile->commerce_customer_address[LANGUAGE_NONE][0]['locality'] == $edit['commerce_customer_address[und][0][locality]'], t('\'Locality\' field has been correctly modified in the customer profile'));
    $this
      ->assertTrue($profile->uid == 0, t('Profile owner is now anonymous user'));
  }

  /**
   * Disable a customer profile.
   * @TODO: Probably this test should be completed when it is possible to
   * select older profiles for the orders.
   */
  public function testCommerceCustomerUIDisableCustomerProfile() {

    // Create a new customer profile.
    $profile = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Edit the customer profile.
    $this
      ->drupalPost('admin/commerce/customer-profiles/' . $profile->profile_id . '/edit', array(
      'status' => 0,
    ), t('Save profile'));
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertText(t('Disabled'), t('\'Disabled\' text for the profile appears in the profile listing page'));
    $profiles = commerce_customer_profile_load_multiple(array(
      $profile->profile_id,
    ), array(), TRUE);
    $profile = reset($profiles);
    $this
      ->assertTrue($profile->status == 0, t('Profile status is Disabled'));
  }

  /**
   * Delete a customer profile.
   */
  public function testCommerceCustomerUIDeleteCustomerProfile() {

    // Create a new customer profile.
    $profile = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);

    // Login with customer.
    $this
      ->drupalLogin($this->store_customer);

    // Check the access to the profile delete.
    $this
      ->drupalGet('admin/commerce/customer-profiles/' . $profile->profile_id . '/delete');
    $this
      ->assertResponse(403, t('Store customer is not able to access the admin deletion page for a customer profile'));

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the access to the profile delete.
    $this
      ->drupalGet('admin/commerce/customer-profiles/' . $profile->profile_id . '/delete');
    $this
      ->assertResponse(200, t('Store customer is able to access the admin deletion page for a customer profile'));

    // Check the integrity of the delete form.
    $this
      ->pass(t('Test the integrity of the delete customer profile form:'));
    $this
      ->assertTitle(t('Are you sure you want to delete this profile?') . ' | Drupal', t('The title of the deletion page is correct'));
    $this
      ->assertText(t('Deleting this profile cannot be undone'), t('A warning message for deleting the profile is displayed'));
    $this
      ->assertFieldById('edit-submit', t('Delete'), '\'Delete\' button is present');
    $this
      ->assertLink(t('Cancel'), 0, t('Cancel link is present'));

    // Delete the profile.
    $this
      ->drupalPost(NULL, array(), t('Delete'));

    // Assert the landing page and confirmation messages.
    $this
      ->assertTrue($this->url == url('admin/commerce/customer-profiles', array(
      'absolute' => TRUE,
    )), t('Landing page after deleting the profile is the profile listing page'));
    $this
      ->assertText(t('The profile has been deleted'), t('Confirmation message after deleting the profile is displayed'));
    $this
      ->assertText(t('No customer profiles have been created yet.'), t('\'No customer profiles have been created yet\' message is displayed'));

    // Check at database level.
    $profiles = commerce_customer_profile_load_multiple(array(
      $profile->profile_id,
    ), array(), TRUE);
    $profile = reset($profiles);
    $this
      ->assertTrue(empty($profile), t('Profile can\'t be loaded from database after deleting it'));
  }

  /**
   * Create a customer profile in the process of order creation.
   */
  public function testCommerceCustomerUIAddProfileViaCheckout() {

    // The rule that sends a mail after checkout completion should be disabled
    //  as it returns an error caused by how mail messages are stored.
    $rules_config = rules_config_load('commerce_checkout_order_email');
    $rules_config->active = FALSE;
    $rules_config
      ->save();

    // Create an order.
    $order = $this
      ->createDummyOrder($this->store_customer->uid);

    // Login with customer.
    $this
      ->drupalLogin($this->store_customer);

    // Access checkout.
    $this
      ->drupalGet($this
      ->getCommerceUrl('checkout'));

    // Generate random information, as city, postal code, etc.
    $address_info = $this
      ->generateAddressInformation();

    // Fill in the billing address information
    $billing_pane = $this
      ->xpath("//select[starts-with(@name, 'customer_profile_billing[commerce_customer_address]')]");
    $this
      ->drupalPostAJAX(NULL, array(
      (string) $billing_pane[0]['name'] => 'US',
    ), (string) $billing_pane[0]['name']);

    // Check if the country has been selected correctly, this uses XPath as the
    //  ajax call replaces the element and the id may change
    $this
      ->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected'));

    // Fill in the required information for billing pane, with a random State.
    $info = array(
      'customer_profile_billing[commerce_customer_address][und][0][name_line]' => $address_info['name_line'],
      'customer_profile_billing[commerce_customer_address][und][0][thoroughfare]' => $address_info['thoroughfare'],
      'customer_profile_billing[commerce_customer_address][und][0][locality]' => $address_info['locality'],
      'customer_profile_billing[commerce_customer_address][und][0][administrative_area]' => 'KY',
      'customer_profile_billing[commerce_customer_address][und][0][postal_code]' => $address_info['postal_code'],
    );
    $this
      ->drupalPost(NULL, $info, t('Continue to next step'));

    // Finish checkout process
    $this
      ->drupalPost(NULL, array(), t('Continue to next step'));

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the customer profile at database level.
    $orders = commerce_order_load_multiple(array(
      $order->order_id,
    ), array(), TRUE);
    $order = reset($orders);
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    $profile = $order_wrapper->commerce_customer_billing
      ->value();
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    $address = $profile_wrapper->commerce_customer_address
      ->value();
    $this
      ->assertTrue(array_intersect($address_info, $address) == $address_info, t('The address info for the checkout is stored in the customer profile'));

    // Check the customer profile in the listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertTrue($address['name_line'], t('\'Name line\' text is present with the correct value: !value', array(
      '!value' => $address['name_line'],
    )));
  }

  /**
   * Add a customer profile using the Order interface.
   */
  public function testCommerceCustomerUIAddProfileViaOrderUI() {

    // Create an order for store customer.
    $order = $this
      ->createDummyOrder($this->store_customer->uid, array(), 'pending');

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Access the order and fill customer profile information.
    $this
      ->drupalGet('admin/commerce/orders/' . $order->order_id . '/edit');
    $address_info = $this
      ->generateAddressInformation();

    // Add a billing information profile to the order.
    $this
      ->drupalPostAJAX(NULL, array(), array(
      'op' => t('Add billing information'),
    ));
    $billing_country = $this
      ->xpath("//select[starts-with(@name, 'commerce_customer_billing')]");
    $this
      ->drupalPostAJAX(NULL, array(
      (string) $billing_country[0]['name'] => variable_get('site_default_country', 'US'),
    ), (string) $billing_country[0]['name']);

    // Fill the profile information and Save.
    $info = array(
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]' => $address_info['name_line'],
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][thoroughfare]' => $address_info['thoroughfare'],
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]' => $address_info['locality'],
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][administrative_area]' => $address_info['administrative_area'],
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][postal_code]' => $address_info['postal_code'],
    );
    $this
      ->drupalPost(NULL, $info, t('Save order'));
    $this
      ->assertText(t('Order saved'), t('\'Order saved\' message is displayed'));

    // Check the customer profile in the listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertTrue($address_info['name_line'], t('\'Name line\' text is present with the correct value: !value', array(
      '!value' => $address_info['name_line'],
    )));

    // Check the customer profile at database level.
    $conditions = array();
    foreach ($address_info as $id => $element) {
      $conditions[] = array(
        'field' => 'commerce_customer_address',
        'column' => $id,
        'value' => $element,
      );
    }
    $profiles = $this
      ->loadCustomerProfile($conditions);
    $profile = commerce_customer_profile_load(reset($profiles)->profile_id);
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    $this
      ->assertFalse(empty($profile), t('Profile has been created in database'));
    foreach ($address_info as $name => $info) {
      $this
        ->assertEqual($profile_wrapper->commerce_customer_address->{$name}
        ->value(), $info, t('!name is present in the profile with value !value', array(
        '!name' => $name,
        '!value' => $info,
      )));
    }
  }

  /**
   * Edit a customer profile through the order UI.
   */
  public function testCommerceCustomerUIEditProfileViaOrderUI() {

    // Create a new customer profile.
    $profile = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);

    // Create an order for store customer.
    $order = $this
      ->createDummyOrder($this->store_customer->uid, array(), 'pending', $profile->profile_id);

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Change some profile fields in the order and save.
    $edit = array(
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]' => 'Example Name line',
      'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]' => 'Example Locality',
    );
    $this
      ->drupalPost('admin/commerce/orders/' . $order->order_id . '/edit', $edit, t('Save order'));
    $this
      ->assertText(t('Order saved'), t('\'Order saved\' message is displayed'));

    // Check the customer profile in the listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertTrue($edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'], t('\'Name line\' text is present with the correct value: !value', array(
      '!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'],
    )));

    // Check the customer profile at database level.
    $profiles = commerce_customer_profile_load_multiple(array(
      $profile->profile_id,
    ), array(), TRUE);
    $profile = reset($profiles);
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    $this
      ->assertEqual($profile_wrapper->commerce_customer_address->name_line
      ->value(), $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'], t('\'Name line\' property value !value match', array(
      '!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'],
    )));
    $this
      ->assertEqual($profile_wrapper->commerce_customer_address->locality
      ->value(), $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]'], t('\'Locality\' property value !value match', array(
      '!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]'],
    )));
  }

  /**
   * Delete a customer profile through the order UI.
   */
  public function testCommerceCustomerUIDeleteProfileViaOrderUI() {

    // Create a new customer profile.
    $profile = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);

    // Create an order for store customer.
    $order = $this
      ->createDummyOrder($this->store_customer->uid, array(), 'pending', $profile->profile_id);

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Access the order and check delete customer profile information.
    $this
      ->drupalPost('admin/commerce/orders/' . $order->order_id . '/edit', array(
      'commerce_customer_billing[und][profiles][0][remove]' => 1,
    ), t('Save order'));

    // Check the customer profile is not present in the listing.
    $this
      ->drupalGet('admin/commerce/customer-profiles');
    $this
      ->assertNoText($profile_wrapper->commerce_customer_address->name_line
      ->value(), t('\'Name line\' for the profile is not present in the customer profiles listing'));

    // Check the customer profile has been deleted at database level.
    $profiles = commerce_customer_profile_load_multiple(array(
      $profile->profile_id,
    ), array(), TRUE);
    $profile = reset($profiles);
    $this
      ->assertTrue(empty($profile), t('Profile has been delete from database'));
  }

  /**
   * Delete multiple profiles with and without orders attached.
   */
  public function testCommerceCustomerDeleteProfilesWithOrderReference() {

    // Create 2 new customer profiles.
    $profile_with_order = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);
    $this
      ->createDummyOrder($this->store_customer->uid, array(), 'pending', $profile_with_order->profile_id);
    $profile_without_order = $this
      ->createDummyCustomerProfile('billing', $this->store_customer->uid);
    $profile_ids = array(
      $profile_with_order->profile_id,
      $profile_without_order->profile_id,
    );

    // Delete the profiles we can.
    commerce_customer_profile_delete_multiple($profile_ids);

    // Check the customer profile has been deleted at database level.
    $profiles = commerce_customer_profile_load_multiple($profile_ids, array(), TRUE);
    $this
      ->assertTrue(!empty($profiles[$profile_with_order->profile_id]), t('Profile with order has not been delete from database'));
    $this
      ->assertTrue(empty($profiles[$profile_without_order->profile_id]), t('Profile without order has been delete from database'));
  }

  /**
   * Create a custom profile type form an helper module and test it.
   */
  public function testCommerceCustomerUINewProfileType() {

    // Enable the helper module that creates a new profile type.
    module_enable(array(
      'commerce_customer_profile_dummy_type',
    ));

    // Login with store admin.
    $this
      ->drupalLogin($this->store_admin);

    // Check the customer profile types.
    $this
      ->drupalGet('admin/commerce/customer-profiles/types');
    $this
      ->assertText(t('Dummy profile type'), t('Dummy profile type is available in the profile types listing page'));

    // Check the order fields.
    $this
      ->drupalGet('admin/commerce/config/order/fields');
    $this
      ->assertText(t('Dummy profile type'), t('Dummy profile type is present in the order reference fields'));

    // Check the checkout panes.
    $this
      ->drupalGet('admin/commerce/config/checkout/form');
    $this
      ->assertText(t('Dummy profile type'), t('Dummy profile type is present as checkout pane'));

    // Create an order for store customer.
    $order = $this
      ->createDummyOrder($this->store_customer->uid, array(), 'pending');

    // Check if the profile type is present.
    $this
      ->drupalGet('admin/commerce/orders/' . $order->order_id . '/edit');
    $this
      ->assertText(t('Dummy profile type'), t('Dummy profile type is present in the order edit form'));
  }

  /**
   * Test the copying of one profile's fields to another (disabled by default).
   */
  public function testCommerceCustomerUIProfileCopy() {
    $this
      ->_testCommerceCustomerUIProfileCopy();
  }

  /**
   * Test the copying of one profile's fields to another (enabled by default).
   */
  public function testCommerceCustomerUIProfileCopyDefaultEnabled() {
    $this
      ->_testCommerceCustomerUIProfileCopy(TRUE);
  }

  /**
   * Test the copying of one profile's fields to another.
   */
  public function _testCommerceCustomerUIProfileCopy($default_enabled = FALSE) {

    // Enable the helper module that creates a new profile type.
    module_enable(array(
      'commerce_customer_profile_dummy_type',
    ));

    // Configure the dummy profile type's checkout pane to allow copying from
    // the billing information customer profile type.
    variable_set('commerce_customer_profile_dummy_profile_copy', TRUE);
    variable_set('commerce_customer_profile_dummy_profile_copy_source', 'billing');
    variable_set('commerce_customer_profile_dummy_profile_copy_default', $default_enabled);

    // Create an order.
    $order = $this
      ->createDummyOrder($this->store_customer->uid);

    // Login with customer.
    $this
      ->drupalLogin($this->store_customer);

    // Access checkout.
    $this
      ->drupalGet($this
      ->getCommerceUrl('checkout'));

    // Generate random information, as city, postal code, etc.
    $address_info = $this
      ->generateAddressInformation();

    // Fill in the billing address information if the copying isn't enabled by default.
    if (!$default_enabled) {
      $billing_pane = $this
        ->xpath("//select[starts-with(@name, 'customer_profile_billing[commerce_customer_address]')]");
      $this
        ->drupalPostAJAX(NULL, array(
        (string) $billing_pane[0]['name'] => 'US',
      ), (string) $billing_pane[0]['name']);
    }

    // Fill in the required information for billing pane, with a random State.
    $info = array(
      'customer_profile_billing[commerce_customer_address][und][0][name_line]' => $address_info['name_line'],
      'customer_profile_billing[commerce_customer_address][und][0][thoroughfare]' => $address_info['thoroughfare'],
      'customer_profile_billing[commerce_customer_address][und][0][locality]' => $address_info['locality'],
      'customer_profile_billing[commerce_customer_address][und][0][administrative_area]' => 'KY',
      'customer_profile_billing[commerce_customer_address][und][0][postal_code]' => $address_info['postal_code'],
      'customer_profile_dummy[commerce_customer_profile_copy]' => 1,
    );
    $this
      ->drupalPostAJAX(NULL, $info, 'customer_profile_dummy[commerce_customer_profile_copy]');
    $this
      ->drupalPost(NULL, $info, t('Continue to next step'));

    // Check the customer profile at database level.
    $orders = commerce_order_load_multiple(array(
      $order->order_id,
    ), array(), TRUE);
    $order = reset($orders);
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

    // Extract the address field value from the billing profile.
    $profile = $order_wrapper->commerce_customer_billing
      ->value();
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    $billing_address = $profile_wrapper->commerce_customer_address
      ->value();

    // And extract the address field value from the dummy profile.
    $profile = $order_wrapper->commerce_customer_dummy
      ->value();
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    $dummy_address = $profile_wrapper->commerce_customer_address
      ->value();
    $this
      ->assertTrue(array_intersect($billing_address, $dummy_address) == $billing_address, t('A billing information customer profile was successfully copied to a dummy customer profile during checkout.'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommerceBaseTestCase::$profile protected property The profile to install as a basis for testing. Overrides DrupalWebTestCase::$profile
CommerceBaseTestCase::assertProductAddedToCart public function Asserts that a product has been added to the cart.
CommerceBaseTestCase::assertProductCreated public function Asserts that a product has been created.
CommerceBaseTestCase::attachProductReferenceField public function Attach a product reference field to a given content type. Creates the field if the given name doesn't already exist. Automatically sets the display formatters to be the "add to cart form" for the teaser and full modes.
CommerceBaseTestCase::createDummyCustomerProfile public function Create a customer profile.
CommerceBaseTestCase::createDummyOrder public function Create a dummy order in a given status.
CommerceBaseTestCase::createDummyProduct public function Creates a dummy product for use with other tests.
CommerceBaseTestCase::createDummyProductDisplayContentType public function Create a dummy product display content type.
CommerceBaseTestCase::createDummyProductNode public function Creates a product display node with an associated product.
CommerceBaseTestCase::createDummyProductNodeBatch public function Create a full product node without worrying about the earlier steps in the process.
CommerceBaseTestCase::createDummyProductType public function Creates a dummy product type for use with other tests.
CommerceBaseTestCase::createDummyTaxRate public function * Create a dummy tax rate. * *
CommerceBaseTestCase::createDummyTaxType public function * Create a dummy tax type. * *
CommerceBaseTestCase::createSiteAdmin protected function Returns a site administrator user. Only has permissions for administering modules in Drupal core.
CommerceBaseTestCase::createStoreAdmin protected function Returns a store administrator user. Only has permissions for administering Commerce modules.
CommerceBaseTestCase::createStoreCustomer protected function Returns a store customer. It's a regular user with some Commerce permissions as access to checkout.
CommerceBaseTestCase::createUserWithPermissionHelper protected function Wrapper to easily create users from arrays returned by permissionBuilder().
CommerceBaseTestCase::enableCurrencies public function Enable extra currencies in the store.
CommerceBaseTestCase::generateAddressInformation protected function Generate random valid information for Address information.
CommerceBaseTestCase::generateEmail protected function Generate a random valid email
CommerceBaseTestCase::getCommerceUrl protected function Return one of the Commerce configured urls.
CommerceBaseTestCase::modulesUp protected function Checks if a group of modules is enabled.
CommerceBaseTestCase::permissionBuilder protected function Helper function to get different combinations of permission sets.
CommerceBaseTestCase::setUpHelper protected function Helper function to determine which modules should be enabled. Should be used in place of standard parent::setUp('moduleA', 'moduleB') call. 1
CommerceCustomerUITest::getInfo public static function Implementation of getInfo().
CommerceCustomerUITest::loadCustomerProfile protected function Load a customer profile basing in field conditions.
CommerceCustomerUITest::setUp function Implementation of setUp(). Overrides DrupalWebTestCase::setUp
CommerceCustomerUITest::testCommerceCustomerDeleteProfilesWithOrderReference public function Delete multiple profiles with and without orders attached.
CommerceCustomerUITest::testCommerceCustomerUIAccessCustomerProfilesListing public function Access to the customer profiles listing.
CommerceCustomerUITest::testCommerceCustomerUIAccessCustomerProfileTypesListing public function Access to the customer profile types listing.
CommerceCustomerUITest::testCommerceCustomerUIAddCustomerProfile public function Add a customer profile.
CommerceCustomerUITest::testCommerceCustomerUIAddCustomerProfileSaveAndAddAnother public function Save and add another customer profile.
CommerceCustomerUITest::testCommerceCustomerUIAddProfileViaCheckout public function Create a customer profile in the process of order creation.
CommerceCustomerUITest::testCommerceCustomerUIAddProfileViaOrderUI public function Add a customer profile using the Order interface.
CommerceCustomerUITest::testCommerceCustomerUIDeleteCustomerProfile public function Delete a customer profile.
CommerceCustomerUITest::testCommerceCustomerUIDeleteProfileViaOrderUI public function Delete a customer profile through the order UI.
CommerceCustomerUITest::testCommerceCustomerUIDisableCustomerProfile public function Disable a customer profile. @TODO: Probably this test should be completed when it is possible to select older profiles for the orders.
CommerceCustomerUITest::testCommerceCustomerUIEditCustomerProfile public function Edit a previously existing customer profile.
CommerceCustomerUITest::testCommerceCustomerUIEditProfileViaOrderUI public function Edit a customer profile through the order UI.
CommerceCustomerUITest::testCommerceCustomerUINewProfileType public function Create a custom profile type form an helper module and test it.
CommerceCustomerUITest::testCommerceCustomerUIProfileCopy public function Test the copying of one profile's fields to another (disabled by default).
CommerceCustomerUITest::testCommerceCustomerUIProfileCopyDefaultEnabled public function Test the copying of one profile's fields to another (enabled by default).
CommerceCustomerUITest::testCommerceCustomerUIProfileWithExtraFields public function Add extra fields to a profile type.
CommerceCustomerUITest::_testCommerceCustomerUIProfileCopy public function Test the copying of one profile's fields to another.
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$useSetupInstallationCache public property Whether to cache the installation part of the setUp() method.
DrupalTestCase::$useSetupModulesCache public property Whether to cache the modules installation part of the setUp() method.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::run public function Run all tests in this class.
DrupalTestCase::verbose protected function Logs a verbose message in a text file.
DrupalWebTestCase::$additionalCurlOptions protected property Additional cURL options.
DrupalWebTestCase::$content protected property The content of the page currently loaded in the internal browser.
DrupalWebTestCase::$cookieFile protected property The current cookie file used by cURL.
DrupalWebTestCase::$cookies protected property The cookies of the page currently loaded in the internal browser.
DrupalWebTestCase::$curlHandle protected property The handle of the current cURL connection.
DrupalWebTestCase::$drupalSettings protected property The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser.
DrupalWebTestCase::$elements protected property The parsed version of the page.
DrupalWebTestCase::$generatedTestFiles protected property Whether the files were copied to the test files directory.
DrupalWebTestCase::$headers protected property The headers of the page currently loaded in the internal browser.
DrupalWebTestCase::$httpauth_credentials protected property HTTP authentication credentials (<username>:<password>).
DrupalWebTestCase::$httpauth_method protected property HTTP authentication method
DrupalWebTestCase::$loggedInUser protected property The current user logged in using the internal browser.
DrupalWebTestCase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing purposes.
DrupalWebTestCase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing purposes.
DrupalWebTestCase::$plainTextContent protected property The content of the page currently loaded in the internal browser (plain text version).
DrupalWebTestCase::$redirect_count protected property The number of redirects followed during the handling of a request.
DrupalWebTestCase::$session_id protected property The current session ID, if available.
DrupalWebTestCase::$session_name protected property The current session name, if available.
DrupalWebTestCase::$url protected property The URL currently loaded in the internal browser.
DrupalWebTestCase::assertField protected function Asserts that a field exists with the given name or ID.
DrupalWebTestCase::assertFieldById protected function Asserts that a field exists in the current page with the given ID and value.
DrupalWebTestCase::assertFieldByName protected function Asserts that a field exists in the current page with the given name and value.
DrupalWebTestCase::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
DrupalWebTestCase::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
DrupalWebTestCase::assertLink protected function Pass if a link with the specified label is found, and optional with the specified index.
DrupalWebTestCase::assertLinkByHref protected function Pass if a link containing a given href (part) is found.
DrupalWebTestCase::assertMail protected function Asserts that the most recently sent e-mail message has the given value.
DrupalWebTestCase::assertMailPattern protected function Asserts that the most recently sent e-mail message has the pattern in it.
DrupalWebTestCase::assertMailString protected function Asserts that the most recently sent e-mail message has the string in it.
DrupalWebTestCase::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
DrupalWebTestCase::assertNoField protected function Asserts that a field does not exist with the given name or ID.
DrupalWebTestCase::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
DrupalWebTestCase::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
DrupalWebTestCase::assertNoFieldByXPath protected function Asserts that a field doesn't exist or its value doesn't match, by XPath.
DrupalWebTestCase::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
DrupalWebTestCase::assertNoLink protected function Pass if a link with the specified label is not found.
DrupalWebTestCase::assertNoLinkByHref protected function Pass if a link containing a given href (part) is not found.
DrupalWebTestCase::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
DrupalWebTestCase::assertNoPattern protected function Will trigger a pass if the perl regex pattern is not present in raw content.
DrupalWebTestCase::assertNoRaw protected function Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertNoResponse protected function Asserts the page did not return the specified response code.
DrupalWebTestCase::assertNoText protected function Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertNoTitle protected function Pass if the page title is not the given string.
DrupalWebTestCase::assertNoUniqueText protected function Pass if the text is found MORE THAN ONCE on the text version of the page.
DrupalWebTestCase::assertOptionSelected protected function Asserts that a select option in the current page is checked.
DrupalWebTestCase::assertPattern protected function Will trigger a pass if the Perl regex pattern is found in the raw content.
DrupalWebTestCase::assertRaw protected function Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertResponse protected function Asserts the page responds with the specified response code.
DrupalWebTestCase::assertText protected function Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertTextHelper protected function Helper for assertText and assertNoText.
DrupalWebTestCase::assertThemeOutput protected function Asserts themed output.
DrupalWebTestCase::assertTitle protected function Pass if the page title is the given string.
DrupalWebTestCase::assertUniqueText protected function Pass if the text is found ONLY ONCE on the text version of the page.
DrupalWebTestCase::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
DrupalWebTestCase::assertUrl protected function Pass if the internal browser's URL matches the given path.
DrupalWebTestCase::buildXPathQuery protected function Builds an XPath query.
DrupalWebTestCase::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
DrupalWebTestCase::checkForMetaRefresh protected function Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
DrupalWebTestCase::checkPermissions protected function Check to make sure that the array of permissions are valid.
DrupalWebTestCase::clickLink protected function Follows a link by name.
DrupalWebTestCase::constructFieldXpath protected function Helper function: construct an XPath for the given set of attributes and value.
DrupalWebTestCase::copySetupCache protected function Copy the setup cache from/to another table and files directory.
DrupalWebTestCase::cronRun protected function Runs cron in the Drupal installed by Simpletest.
DrupalWebTestCase::curlClose protected function Close the cURL handler and unset the handler.
DrupalWebTestCase::curlExec protected function Initializes and executes a cURL request.
DrupalWebTestCase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
DrupalWebTestCase::curlInitialize protected function Initializes the cURL connection.
DrupalWebTestCase::drupalCompareFiles protected function Compare two files based on size and file name.
DrupalWebTestCase::drupalCreateContentType protected function Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateNode protected function Creates a node based on default settings.
DrupalWebTestCase::drupalCreateRole protected function Creates a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalGetAJAX protected function Retrieve a Drupal path or an absolute path and JSON decode the result.
DrupalWebTestCase::drupalGetContent protected function Gets the current raw HTML of requested page.
DrupalWebTestCase::drupalGetHeader protected function Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed…
DrupalWebTestCase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the…
DrupalWebTestCase::drupalGetMails protected function Gets an array containing all e-mails sent during this test case.
DrupalWebTestCase::drupalGetNodeByTitle function Get a node from the database based on its title.
DrupalWebTestCase::drupalGetSettings protected function Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::drupalGetTestFiles protected function Get a list files that can be used in tests.
DrupalWebTestCase::drupalGetToken protected function Generate a token for the currently logged in user.
DrupalWebTestCase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
DrupalWebTestCase::drupalLogin protected function Log in a user with the internal browser.
DrupalWebTestCase::drupalLogout protected function
DrupalWebTestCase::drupalPost protected function Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
DrupalWebTestCase::drupalPostAJAX protected function Execute an Ajax submission.
DrupalWebTestCase::drupalSetContent protected function Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.
DrupalWebTestCase::drupalSetSettings protected function Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
DrupalWebTestCase::getAllOptions protected function Get all option elements, including nested options, in a select.
DrupalWebTestCase::getSelectedItem protected function Get the selected value from a select field.
DrupalWebTestCase::getSetupCacheKey protected function Returns the cache key used for the setup caching.
DrupalWebTestCase::getUrl protected function Get the current URL from the cURL handler.
DrupalWebTestCase::handleForm protected function Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
DrupalWebTestCase::loadSetupCache protected function Copies the cached tables and files for a cached installation setup.
DrupalWebTestCase::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
DrupalWebTestCase::preloadRegistry protected function Preload the registry from the testing site.
DrupalWebTestCase::prepareDatabasePrefix protected function Generates a database prefix for running tests.
DrupalWebTestCase::prepareEnvironment protected function Prepares the current environment for running the test.
DrupalWebTestCase::recursiveDirectoryCopy protected function Recursively copy one directory to another.
DrupalWebTestCase::refreshVariables protected function Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. 1
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::storeSetupCache protected function Store the installation setup to a cache.
DrupalWebTestCase::tearDown protected function Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix. 6
DrupalWebTestCase::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
DrupalWebTestCase::xpath protected function Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.
DrupalWebTestCase::__construct function Constructor for DrupalWebTestCase. Overrides DrupalTestCase::__construct 1