You are here

protected function UcAddressesTestCase::doAddressValuesDisplayedTests in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 tests/UcAddressesTestCase.test \UcAddressesTestCase::doAddressValuesDisplayedTests()

Test if these address values are displayed on the page.

Parameters

array $values: The values that should exist

string $context: (optional) The context in which the address is displayed.

string $output: (optional) The output to test. Defaults to the output in the browser

Return value

void

5 calls to UcAddressesTestCase::doAddressValuesDisplayedTests()
UcAddressesApiTestCase::testAddressOutput in tests/uc_addresses.api.test
Tests if address objects can be converted to a string.
UcAddressesEntityCase::testEntityCrud in tests/uc_addresses.entity.test
Test Ubercart Addresses Entity CRUD.
UcAddressesTestCase::createAddress in tests/UcAddressesTestCase.test
Create a new address for an user.
UcAddressesTestCase::editAddress in tests/UcAddressesTestCase.test
Edit an address of an user.
UcAddressesUserRegistrationTestCase::testRegistration in tests/uc_addresses.register.test
Register the user and assign privileges of the customerDelete account.

File

tests/UcAddressesTestCase.test, line 253
Contains base class for Ubercart Addresses tests.

Class

UcAddressesTestCase
Base class for Ubercart Addresses tests.

Code

protected function doAddressValuesDisplayedTests($values, $context = 'default', $output = NULL) {
  $address = UcAddressesAddressBook::newAddress();
  $handlers = uc_addresses_get_address_field_handler_instances($address, $context);
  foreach ($handlers as $fieldname => $handler) {
    if (!isset($values[$fieldname])) {
      continue;
    }

    // Check if field is used in the context and if it is enabled.
    if ($handler
      ->checkContext() && $handler
      ->isFieldEnabled()) {
      $value = $handler
        ->outputValue($values[$fieldname]);
      if (drupal_strlen($value) > 0) {
        if ($output) {
          $this
            ->assertTrue(strpos($output, $value) !== FALSE, t('Value %value found for field %field on the page.', array(
            '%value' => $value,
            '%field' => $fieldname,
          )));
        }
        else {
          $this
            ->assertText($value, t('Value %value found for field %field on the page.', array(
            '%value' => $value,
            '%field' => $fieldname,
          )));
        }
      }
    }
  }
}