You are here

protected function UcAddressesTestCase::UcAddressesCreateAddresses in Ubercart Addresses 7

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

Create 2 addresses for each passed user:

  • one default address.
  • one other address.

Parameters

object $account: The account to create addresses for.

Return value

void

1 call to UcAddressesTestCase::UcAddressesCreateAddresses()
UcAddressesViewsTestCase::setUp in tests/uc_addresses.views.test
Setup.

File

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

Class

UcAddressesTestCase
Base class for Ubercart Addresses tests.

Code

protected function UcAddressesCreateAddresses($account) {
  $addressBook = UcAddressesAddressBook::get($account->uid);

  // Clear address book cache to clear up leftover addresses
  // from previous tests.
  $addressBook
    ->reset();

  // Create default address.
  $address = $addressBook
    ->addAddress();
  $address
    ->setField('last_name', self::randomName());
  $address
    ->setAsDefault();
  $address
    ->setName($account->uid . '_default');

  // Create other address.
  $address = $addressBook
    ->addAddress();
  $address
    ->setField('last_name', self::randomName());
  $address
    ->setName($account->uid . '_other');

  // Save all addresses.
  $addressBook
    ->save();
}