You are here

protected function UcAddressesCartCheckoutTestCase::checkCheckoutAddressFields in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 tests/uc_addresses.checkout.test \UcAddressesCartCheckoutTestCase::checkCheckoutAddressFields()

Checks values on checkout form for given address and type.

Parameters

string $order_address_type: The type of address on the checkout form the check values for: delivery or billing.

UcAddressesAddress $address: The address to check values against.

1 call to UcAddressesCartCheckoutTestCase::checkCheckoutAddressFields()
UcAddressesCartCheckoutTestCase::doDefaultAddressesTests in tests/uc_addresses.checkout.test
Checkout with the default addresses.

File

tests/uc_addresses.checkout.test, line 261
Test cases for checkout.

Class

UcAddressesCartCheckoutTestCase
Test cases for checkout.

Code

protected function checkCheckoutAddressFields($order_address_type, $address) {
  $handlers = uc_addresses_get_address_field_handler_instances($address, 'checkout_form');
  foreach ($handlers as $fieldname => $handler) {
    if ($handler
      ->checkContext()) {
      $field_id = 'edit-panes-' . $order_address_type . '-' . $order_address_type . '-' . $order_address_type . '-' . $fieldname;
      $field_id = form_clean_id($field_id);
      $value = $address
        ->getField($fieldname);
      $message_variables = array(
        '@address_type' => $order_address_type,
        '%field' => $handler
          ->getFieldTitle(),
        '%value' => $value,
      );
      if (empty($value)) {
        $message = t('The @address_type field %field is empty.', $message_variables);
      }
      else {
        $message = t('The @address_type field %field contains %value.', $message_variables);
      }
      $this
        ->assertFieldById($field_id, $value, $message);
    }
  }
}