You are here

private function FeatureContext::fillCommerceAddress in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Fill commerce address form fields in a single step.

2 calls to FeatureContext::fillCommerceAddress()
FeatureContext::fillBillingCommerceAddress in test/features/bootstrap/FeatureContext.php
Fill the commerce billing address form fields in a single step.
FeatureContext::fillShippingCommerceAddress in test/features/bootstrap/FeatureContext.php
Fill the commerce shipping address form fields in a single step.

File

test/features/bootstrap/FeatureContext.php, line 916

Class

FeatureContext
Features context.

Code

private function fillCommerceAddress($args, $type) {

  // Replace <random> or member <property> token if is set for any field
  foreach ($args as $delta => $arg) {
    if (preg_match("/^<random>\$/", $arg, $matches)) {
      $random = new Random();
      $args[$delta] = $random
        ->name();
    }
  }

  // Need to manually fill country to trigger the AJAX refresh of fields for given country
  $country_field = str_replace('\\"', '"', "{$type}[commerce_customer_address][und][0][country]");
  $country_value = str_replace('\\"', '"', $args[4]);
  $this
    ->getSession()
    ->getPage()
    ->fillField($country_field, $country_value);
  $this->minkContext
    ->iWaitForAjaxToFinish();
  $this->minkContext
    ->fillField("{$type}[commerce_customer_address][und][0][locality]", $args[1]);
  $this->minkContext
    ->fillField("{$type}[commerce_customer_address][und][0][administrative_area]", $args[2]);
  $this->minkContext
    ->fillField("{$type}[commerce_customer_address][und][0][postal_code]", $args[3]);
  $this->minkContext
    ->fillField("{$type}[commerce_customer_address][und][0][thoroughfare]", $args[0]);
}