You are here

public function UbercartAddressTestCase::createAddress in Ubercart 7.3

Creates an address object based on default settings.

Parameters

$settings: An associative array of settings to change from the defaults, keys are address properties. For example, 'city' => 'London'.

Return value

UcAddress object.

1 call to UbercartAddressTestCase::createAddress()
UbercartAddressTestCase::setUp in uc_store/tests/uc_address.test
Overrides DrupalWebTestCase::setUp().

File

uc_store/tests/uc_address.test, line 100
Tests for the UcAddress class.

Class

UbercartAddressTestCase
Tests for the UcAddress class.

Code

public function createAddress($settings = array()) {
  $street = array_flip(array(
    'Street',
    'Avenue',
    'Place',
    'Way',
    'Road',
    'Boulevard',
    'Court',
  ));

  // Populate object with defaults.
  $address = new UcAddress();
  $address->first_name = $this
    ->randomName(6);
  $address->last_name = $this
    ->randomName(12);
  $address->company = $this
    ->randomName(10) . ', Inc.';
  $address->street1 = mt_rand(100, 1000) . ' ' . $this
    ->randomName(10) . ' ' . array_rand($street);
  $address->street2 = 'Suite ' . mt_rand(100, 999);
  $address->city = $this
    ->randomName(10);
  $address->zone = 23;
  $address->country = 840;
  $address->postal_code = mt_rand(10000, 99999);
  $address->phone = '(' . mt_rand(100, 999) . ') ' . mt_rand(100, 999) . '-' . mt_rand(0, 9999);
  $address->email = $this
    ->randomName(6) . '@' . $this
    ->randomName(8) . '.com';
  foreach ($settings as $property => $value) {
    $address->{$property} = $value;
  }
  return $address;
}