You are here

class UcAddressesApiTestCase in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 tests/uc_addresses.api.test \UcAddressesApiTestCase

Test cases for the api component.

Hierarchy

Expanded class hierarchy of UcAddressesApiTestCase

File

tests/uc_addresses.api.test, line 14
Test cases for the api component.

View source
class UcAddressesApiTestCase extends UcAddressesTestCase {

  /**
   * Describes this test.
   *
   * @return array
   */
  public static function getInfo() {
    return array(
      'name' => 'Unit testing',
      'description' => 'Ensure that the API behaves as expected.',
      'group' => 'Ubercart Addresses',
      'dependencies' => array(
        'ctools',
        'token',
        'uc_store',
      ),
    );
  }

  /**
   * Tests if addresses can be added, saved and deleted.
   */
  public function testAddressBookCrud() {

    // First, get the address book of the admin user.
    $addressBook = $this
      ->UcAddressesGetAddressBook($this->adminUser->uid);

    // Add a new address.
    $address1 = $addressBook
      ->addAddress();

    // Ensure the address book has exactly one address in its registry.
    $this
      ->assertEqual(count($addressBook
      ->getAddresses()), 1, 'The address book contains exactly one address.');

    // Try to delete the address again and test again how many addresses the address book contains (should be 0).
    $address1
      ->delete();
    $this
      ->assertEqual(count($addressBook
      ->getAddresses()), 0, 'The address book contains no addresses.');

    // Add a new address and ensure it is new.
    $address2 = $addressBook
      ->addAddress();
    $this
      ->assertTrue($address2
      ->isNew(), 'The address is new.');

    // Fill the address (all field values should be present).
    $values = self::getEditAddressValues();
    $address2
      ->setMultipleFields($values['values'], TRUE);

    // Save all addresses in the address book and ensure the address is no longer new (thus has a definitive address ID).
    $addressBook
      ->save();
    $this
      ->assertFalse($address2
      ->isNew(), 'The address is no longer new.');

    // Check if the address exists in the database.
    $this
      ->assertTrue(self::checkAddressValuesInDatabase($values['values']), 'The address is correctly saved to the database.');

    // Reset the address book.
    $addressBook
      ->reset();

    // Try to get the address for the user.
    $address2_2 = $addressBook
      ->getAddressById($address2
      ->getId());

    // Ensure these two addresses have the same ID.
    $this
      ->assertEqual($address2_2
      ->getId(), $address2
      ->getId(), t('Address %aid succesfully loaded from the database.', array(
      '%aid' => $address2
        ->getId(),
    )));

    // Reset the address book again.
    $addressBook
      ->reset();

    // Try to delete the address.
    $this
      ->assertTrue($addressBook
      ->deleteAddressById($address2
      ->getId()), t('Address %aid is deleted.', array(
      '%aid' => $address2
        ->getId(),
    )));

    // Ensure the database table is empty now.
    $number_of_addresses = db_result(db_query("SELECT COUNT(aid) AS number_of_addresses FROM {uc_addresses}"));
    $this
      ->assertEqual($number_of_addresses, 0, 'There are no addresses in the uc_addresses table.');
  }

  /**
   * Tests unique address names.
   */
  public function testAddressNames() {
    $addressBook = $this
      ->UcAddressesGetAddressBook($this->adminUser->uid);

    // Add a new address and give it a name.
    $address1 = $addressBook
      ->addAddress();
    $addressBook
      ->setAddressAsDefault($address1, 'billing');
    $name = self::randomName(12);
    $address1
      ->setName($name);
    $address1
      ->save();

    // Ensure the address has the name assigned.
    $this
      ->assertEqual($address1
      ->getName(), $name, t('Address %aid got the name %name.', array(
      '%aid' => $address1
        ->getId(),
      '%name' => $name,
    )));

    // Reset the address book.
    $addressBook
      ->reset();

    // Add a new address and try to give it the same name as address1.
    $address2 = $addressBook
      ->addAddress();
    $address2
      ->setName($name);

    // Ensure address2 has NOT the name assigned.
    $this
      ->assertNotEqual($address2
      ->getName(), $name, t('Address %aid does not got the name %name.', array(
      '%aid' => $address2
        ->getId(),
      '%name' => $name,
    )));

    // Try to delete address1 (should not be possible, because address should be a default address).
    $this
      ->assertFalse($addressBook
      ->deleteAddressByName($name), t('Address %name is not deleted.', array(
      '%name' => $name,
    )));

    // Make address2 the default and try again.
    $addressBook
      ->setAddressAsDefault($address2, 'billing');
    $this
      ->assertTrue($addressBook
      ->deleteAddressByName($name), t('Address %name is deleted.', array(
      '%name' => $name,
    )));
  }

  /**
   * Tests default addresses.
   */
  public function testDefaultAddresses() {
    $addressBook = $this
      ->UcAddressesGetAddressBook($this->adminUser->uid);

    // Create a new address and mark it as default billing.
    $address1 = $addressBook
      ->addAddress();
    $addressBook
      ->setAddressAsDefault($address1, 'billing');
    $address1
      ->save();

    // Ensure that the address is the default billing address.
    $default_billing_aid = db_result(db_query("SELECT aid FROM {uc_addresses} WHERE default_billing = 1"));
    $this
      ->assertEqual($address1
      ->getId(), $default_billing_aid, 'The address is the default billing address.');

    // Reset the address book.
    $addressBook
      ->reset();

    // Try to delete address1. This should not be possible, because
    // deleting default addresses is not allowed.
    $this
      ->assertFalse($addressBook
      ->deleteAddressById($address1
      ->getId()), t('Address %aid is not deleted.', array(
      '%aid' => $address1
        ->getId(),
    )));

    // Create a new address and delete the first one.
    $address2 = $addressBook
      ->addAddress();
    $addressBook
      ->setAddressAsDefault($address2, 'billing');
    $this
      ->assertTrue($addressBook
      ->deleteAddressById($address1
      ->getId()), t('Address %aid is deleted.', array(
      '%aid' => $address1
        ->getId(),
    )));

    // Ensure the database table is empty now ($address2 is not yet saved).
    $number_of_addresses = db_result(db_query("SELECT COUNT(aid) AS number_of_addresses FROM {uc_addresses}"));
    $this
      ->assertEqual($number_of_addresses, 0, 'There are no addresses in the uc_addresses table.');

    // Now save $address2 and ensure that this address is the default
    // billing address in the database.
    $address2
      ->save();
    $default_billing_aid = db_result(db_query("SELECT aid FROM {uc_addresses} WHERE default_billing = 1"));
    $this
      ->assertEqual($address2
      ->getId(), $default_billing_aid, 'The address is the default billing address.');

    // Create a third address and mark this as default billing as well.
    $address3 = $addressBook
      ->addAddress();
    $addressBook
      ->setAddressAsDefault($address3, 'billing');
    $address3
      ->save();

    // Ensure the user has only one default billing address.
    $number_of_addresses = (int) db_result(db_query("SELECT COUNT(aid) AS number_of_addresses FROM {uc_addresses} WHERE default_billing = 1"));
    $this
      ->assertEqual($number_of_addresses, 1, 'The database contains one default billing address.');
  }

  /**
   * Tests the address book's performance hint setting.
   */
  public function testPerformanceHintSetting() {
    $addressBook = $this
      ->UcAddressesGetAddressBook($this->adminUser->uid);

    // Add three addresses and save them all.
    for ($i = 0; $i < 3; $i++) {
      $address = $addressBook
        ->addAddress();
      $values = self::getEditAddressValues();
      $address
        ->setMultipleFields($values['values'], TRUE);
    }
    $addressBook
      ->save();

    // Get addresses for later use.
    $addresses = $addressBook
      ->getAddresses();

    // Make sure we have three addresses.
    $this
      ->assertEqual(count($addresses), 3, 'The address book contains 3 addresses.');

    // Reset the address book.
    $addressBook
      ->reset();

    // Ensure the performance hint is set to load a single address.
    $addressBook
      ->setPerformanceHint(UcAddressesAddressBook::PERF_HINT_LOAD_ONE);
    $this
      ->assertEqual($addressBook
      ->getPerformanceHint(), UcAddressesAddressBook::PERF_HINT_LOAD_ONE, 'Performance hint is set to PERF_HINT_LOAD_ONE.');

    // Load the first address.
    $address1 = reset($addresses);
    $addressBook
      ->getAddressById($address1
      ->getId());

    // Check if the only address that is loaded now is $address1.
    foreach ($addresses as $address) {
      if ($address
        ->getId() == $address1
        ->getId()) {

        // The address should be loaded.
        $this
          ->assertTrue($addressBook
          ->addressExists($address
          ->getId()), t('Address %aid is loaded.', array(
          '%aid' => $address
            ->getId(),
        )));
      }
      else {

        // The address should not be loaded.
        $this
          ->assertFalse($addressBook
          ->addressExists($address
          ->getId()), t('Address %aid is not loaded.', array(
          '%aid' => $address
            ->getId(),
        )));
      }
    }

    // Reset the address book again.
    $addressBook
      ->reset();

    // Ensure the performance hint is set to load all address.
    $addressBook
      ->setPerformanceHint(UcAddressesAddressBook::PERF_HINT_LOAD_ALL);
    $this
      ->assertEqual($addressBook
      ->getPerformanceHint(), UcAddressesAddressBook::PERF_HINT_LOAD_ALL, 'Performance hint is set to PERF_HINT_LOAD_ALL.');

    // Load address1.
    $addressBook
      ->getAddressById($address1
      ->getId());

    // Check if all address are loaded.
    foreach ($addresses as $address) {

      // Each address should be loaded.
      $this
        ->assertTrue($addressBook
        ->addressExists($address
        ->getId()), t('Address %aid is loaded.', array(
        '%aid' => $address
          ->getId(),
      )));
    }

    // Set performance hint back to load one.
    $addressBook
      ->setPerformanceHint(UcAddressesAddressBook::PERF_HINT_LOAD_ONE);
  }

  /**
   * Tests if address loading works as expected across
   * multiple address books.
   */
  public function testMultipleAddressBooks() {

    // Get address books from two users.
    $addressBook1 = $this
      ->UcAddressesGetAddressBook($this->adminUser->uid);
    $addressBook2 = $this
      ->UcAddressesGetAddressBook($this->customer->uid);

    // Add an address to the first address book.
    $address1 = $addressBook1
      ->addAddress();
    $values = self::getEditAddressValues();
    $address1
      ->setMultipleFields($values['values'], TRUE);
    $address1
      ->save();

    // Ensure this address can't be get from address book 2.
    $this
      ->assertFalse($addressBook2
      ->getAddressById($address1
      ->getId()), t('Address %aid does not belong to user %uid.', array(
      '%aid' => $address1
        ->getId(),
      '%uid' => $addressBook2
        ->getUserId(),
    )));

    // Reset the first address book.
    $addressBook1
      ->reset();

    // Ensure addresses are equal when either getAddressById() or loadAddress() is used.
    $address1_1 = $addressBook1
      ->getAddressById($address1
      ->getId());
    $address1_2 = UcAddressesAddressBook::loadAddress($address1
      ->getId());
    $this
      ->assertTrue($address1_1 === $address1_2, 'UcAddressesAddressBook::loadAddress() loads exactly the same address as $addressBook->getAddressById().');

    // Try to load a non-existent address using the addressBook's getAddressById() method.
    $this
      ->assertFalse($addressBook1
      ->getAddressById(997), 'Address 997 does not exists.');

    // Try again, but now using the loadAddress() method.
    $this
      ->assertFalse(UcAddressesAddressBook::loadAddress(998), 'Address 998 does not exists.');

    // Set performance hint of address book 1 to load all and ensure that this setting
    // is unchanged in address book 2.
    $addressBook1
      ->setPerformanceHint(UcAddressesAddressBook::PERF_HINT_LOAD_ALL);
    $this
      ->assertEqual($addressBook2
      ->getPerformanceHint(), UcAddressesAddressBook::PERF_HINT_LOAD_ONE, 'Performance hint is set to PERF_HINT_LOAD_ONE.');
  }

  /**
   * Tests if a proper address format is generated when there is
   * no default country set.
   */
  public function testAddressFormatWithoutDefaultCountry() {
    $this
      ->drupalLogin($this->adminUser);

    // Ensure there is no store country set.
    variable_del('uc_store_country');

    // Remove the U.S. country from Ubercart.
    // This will leave Canada as the only available country.
    $country_id = 840;
    db_query("DELETE FROM {uc_countries} WHERE country_id = %d", $country_id);
    db_query("DELETE FROM {uc_zones} WHERE zone_country_id = %d", $country_id);
    variable_del('uc_address_format_' . $country_id);

    // Adjust the address format for Canada.
    $canada_address_format = self::randomName();
    $this
      ->verbose($canada_address_format);
    variable_set('uc_addresses_address_format_124', $canada_address_format);

    // Disable the country field.
    $address_fields = variable_get('uc_address_fields', drupal_map_assoc(array(
      'first_name',
      'last_name',
      'phone',
      'company',
      'street1',
      'street2',
      'city',
      'zone',
      'postal_code',
      'country',
    )));
    unset($address_fields['country']);
    variable_set('uc_address_fields', $address_fields);

    // Create an address.
    $aid = $this
      ->createAddress($this->adminUser);
    $addressBook = UcAddressesAddressBook::get($this->adminUser->uid);
    $addressBook
      ->reset();
    $address = $addressBook
      ->getAddressById($aid);
    if ($address instanceof UcAddressesAddress) {

      // Ensure Canada is used for the address.
      $this
        ->assertEqual($address
        ->getField('country'), '124', strtr('Canada is used as the default country. (ID = !country_id)', array(
        '!country_id' => $address
          ->getField('country'),
      )));

      // Output the address for display.
      $this
        ->viewAddress($this->adminUser, $address
        ->getId());

      // Ensure Canada's address format is used.
      $this
        ->assertText($canada_address_format, 'The address format for Canada was used for the address label.');

      // Test also if the displayed address is not empty
      // when a country is used that does not exists.
      $address
        ->setField('country', 1234);
      $address
        ->save();
      $this
        ->viewAddress($this->adminUser, $address
        ->getId());
      $this
        ->assertText($address
        ->getFieldValue('last_name'), 'Last name was found in the outputted address label.');
      $this
        ->assertText($address
        ->getFieldValue('city'), 'City was found in the outputted address label.');
    }
  }

  /**
   * Tests field handler with an UcAddressesSchemaAddress.
   */
  public function testFieldHandlerApi() {
    $schemaAddress = new UcAddressesSchemaAddress();
    $addressBookAddress = UcAddressesAddressBook::newAddress();
    $address_values = self::getEditAddressValues();
    foreach ($address_values['values'] as $field => $value) {
      $schemaAddress
        ->setField($field, $value);
      $addressBookAddress
        ->setField($field, $value);
    }

    // Test each handler in action.
    foreach ($address_values['values'] as $field => $value) {
      $vars = array(
        '%field' => $field,
      );
      $handler = $schemaAddress
        ->getHandler($field);
      $this
        ->assertTrue($handler instanceof UcAddressesFieldHandler, t('The handler for field %field is UcAddressesFieldHandler.', $vars));
      $this
        ->doHandlerTests($schemaAddress, $field, $handler);
    }

    // Assert that handlers for fields 'name', 'default_shipping' and
    // 'default_billing' can't be used with an UcAddressesSchemaAddress
    // instance.
    foreach (array(
      'address_name',
      'default_shipping',
      'default_billing',
    ) as $field) {
      $vars = array(
        '%field' => $field,
      );
      $handler = $schemaAddress
        ->getHandler($field);
      $this
        ->assertTrue($handler instanceof UcAddressesMissingFieldHandler, t('The handler for field %field is UcAddressesMissingFieldHandler when using UcAddressesSchemaAddress.', $vars));

      // Ensure that calling methods from a missing handler doesn't result into
      // fatal errors.
      $this
        ->doHandlerTests($schemaAddress, $field, $handler);

      // Ensure that the handler is not missing for this field with an
      // UcAddressesAddress instance.
      $handler = $addressBookAddress
        ->getHandler($field);
      $this
        ->assertFalse($handler instanceof UcAddressesMissingFieldHandler, t('The handler for field %field is not UcAddressesMissingFieldHandler when using UcAddressesAddress.', $vars));
    }
  }

  /**
   * Do handler tests.
   *
   * @param UcAddressesSchemaAddress $address
   *   The address that requested the handler.
   * @param string $field
   *   The field that belongs to the handler.
   * @param UcAddressesFieldHandler $handler
   *   The handler to test.
   *
   * @return void
   */
  protected function doHandlerTests(UcAddressesSchemaAddress $address, $field, UcAddressesFieldHandler $handler) {
    $vars = array(
      '%field' => $field,
    );
    $address_values1 = array();
    $value1 = self::generateAddressFieldValue($field, $address_values1);
    $address_values2 = array();
    $value2 = self::generateAddressFieldValue($field, $address_values2);

    // Getters.
    $this
      ->assertEqual($handler
      ->getFieldName(), $field, t('The method getFieldName() for field %field returns the expected value.', $vars));
    $this
      ->assertEqual($handler
      ->getAddress(), $address, t('The method getAddress() for field %field returns the expected value.', $vars));
    $this
      ->assertTrue(is_string($handler
      ->getContext()), t('The method getContext() for field %field returns the expected format.', $vars));
    $this
      ->assertTrue(is_string($handler
      ->getFieldTitle()), t('The method getFieldTitle() for field %field returns the expected format.', $vars));
    $form = array();
    $form_state = array();
    $form[$field] = $handler
      ->getFormField($form, $form_state);
    drupal_prepare_form('dummy', $form, $form_state);
    $form['#post'] = $_POST;
    drupal_process_form('dummy', $form, $form_state);
    $render = drupal_render_form('dummy', $form);
    $this
      ->assertTrue(is_bool($handler
      ->isFieldEnabled()), t('The method isFieldEnabled() for field %field returns the expected format.', $vars));
    $this
      ->assertTrue(is_bool($handler
      ->isFieldRequired()), t('The method isFieldRequired() for field %field returns the expected format.', $vars));

    // Setters.
    $handler
      ->setValue($value1);
    $this
      ->assertEqual($address
      ->getField($field), $value1, t('The method setValue() had set the expected value.', $vars));

    // Action.
    $handler
      ->validateValue($value2);
    $this
      ->assertTrue(is_bool($handler
      ->checkContext()), t('The method checkContext() for field %field returns the expected format.', $vars));

    // Output.
    $this
      ->assertTrue(is_array($handler
      ->getOutputFormats()), t('The method getOutputFormats() for field %field returns the expected format.', $vars));
    $this
      ->assertTrue(is_string($handler
      ->outputValue()), t('The method outputValue() for field %field returns the expected format.', $vars));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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::$originalPrefix protected property The original database prefix, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
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::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.
DrupalTestCase::errorHandler public function Handle errors during test runs.
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::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 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::$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::$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::$profile protected property The profile to install as a basis for testing.
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 does not exist in the current page by the given 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::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::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::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 Internal helper function; Create a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions. The permissions correspond to the names given on the privileges page.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
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::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::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::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
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.
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::tearDown protected function Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.
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
UcAddressesApiTestCase::doHandlerTests protected function Do handler tests.
UcAddressesApiTestCase::getInfo public static function Describes this test.
UcAddressesApiTestCase::testAddressBookCrud public function Tests if addresses can be added, saved and deleted.
UcAddressesApiTestCase::testAddressFormatWithoutDefaultCountry public function Tests if a proper address format is generated when there is no default country set.
UcAddressesApiTestCase::testAddressNames public function Tests unique address names.
UcAddressesApiTestCase::testDefaultAddresses public function Tests default addresses.
UcAddressesApiTestCase::testFieldHandlerApi public function Tests field handler with an UcAddressesSchemaAddress.
UcAddressesApiTestCase::testMultipleAddressBooks public function Tests if address loading works as expected across multiple address books.
UcAddressesApiTestCase::testPerformanceHintSetting public function Tests the address book's performance hint setting.
UcAddressesTestCase::$adminUser protected property Admin user that has all the privileges of uc_addresses.
UcAddressesTestCase::$basicUser protected property An account with no privileges, will be used to create addresses for by other users.
UcAddressesTestCase::$customer protected property Customer who may view, edit and delete own addresses.
UcAddressesTestCase::assertAddressLabel protected function Pass if an address label is found on the page.
UcAddressesTestCase::assertNoAddressLabel protected function Pass if an address label is NOT found on the page.
UcAddressesTestCase::checkAddressValuesInDatabase public static function Test if these address values appear in the database.
UcAddressesTestCase::constructAddressUrl protected function Constructs the url for the address book.
UcAddressesTestCase::createAddress protected function Create a new address for an user.
UcAddressesTestCase::deleteAddress protected function Delete an address of an user.
UcAddressesTestCase::doAddressValuesDisplayedTests protected function Test if these address values are displayed on the page.
UcAddressesTestCase::doCrudTests protected function Test if user can view, edit or delete the address.
UcAddressesTestCase::editAddress protected function Edit an address of an user.
UcAddressesTestCase::generateAddressFieldValue public static function Generates a value for an address field.
UcAddressesTestCase::getEditAddressValues public static function Generates an array of values to post into an address form
UcAddressesTestCase::setUp public function Install users and modules needed for all tests. Overrides DrupalWebTestCase::setUp 2
UcAddressesTestCase::UcAddressesCreateAddresses protected function Create 2 addresses for each passed user:
UcAddressesTestCase::UcAddressesCreateUser protected function Creates a single user and registers which permissions this user should get.
UcAddressesTestCase::UcAddressesGetAddressBook protected function Returns an empty address book to be used in tests.
UcAddressesTestCase::viewAddress protected function View a single address of an user.
UcAddressesTestCase::viewAddressBook protected function View the address book of an user.