You are here

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

@Given /^customer profiles:$/

File

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

Class

FeatureContext
Features context.

Code

public function createCustomerProfiles(TableNode $nodesTable) {
  foreach ($nodesTable
    ->getHash() as $nodeHash) {
    $profile = commerce_customer_profile_new('billing', isset($this->user->uid) ? $this->user->uid : 0);
    $wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    if (isset($nodeHash['country'])) {
      $wrapper->commerce_customer_address->country = $nodeHash['country'];
    }
    if (isset($nodeHash['name'])) {
      $wrapper->commerce_customer_address->name_line = $nodeHash['name'];
    }
    if (isset($nodeHash['address'])) {
      $wrapper->commerce_customer_address->thoroughfare = $nodeHash['address'];
    }
    if (isset($nodeHash['locality'])) {
      $wrapper->commerce_customer_address->locality = $nodeHash['locality'];
    }
    if (isset($nodeHash['postal_code'])) {
      $wrapper->commerce_customer_address->postal_code = $nodeHash['postal_code'];
    }
    $wrapper
      ->save();
    if (isset($nodeHash['profile_id'])) {
      $this->customerProfiles[$nodeHash['profile_id']] = $wrapper->profile_id
        ->value();
    }
    else {
      $this->customerProfiles[] = $wrapper->profile_id
        ->value();
    }
  }
}