You are here

protected function AddressBookTest::setUp in Commerce Core 8.2

Same name in this branch
  1. 8.2 modules/order/tests/src/FunctionalJavascript/AddressBookTest.php \Drupal\Tests\commerce_order\FunctionalJavascript\AddressBookTest::setUp()
  2. 8.2 modules/order/tests/src/Kernel/AddressBookTest.php \Drupal\Tests\commerce_order\Kernel\AddressBookTest::setUp()

Overrides OrderKernelTestBase::setUp

File

modules/order/tests/src/Kernel/AddressBookTest.php, line 58

Class

AddressBookTest
Tests the address book.

Namespace

Drupal\Tests\commerce_order\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this->addressBook = $this->container
    ->get('commerce_order.address_book');
  $this->user = $this
    ->createUser([
    'mail' => 'user1@example.com',
  ]);

  // Create a default profile for the current user.
  $this->defaultProfile = Profile::create([
    'type' => 'customer',
    'uid' => $this->user
      ->id(),
    'address' => [
      'country_code' => 'US',
      'administrative_area' => 'CA',
      'locality' => 'Mountain View',
      'postal_code' => '94043',
      'address_line1' => '1098 Alta Ave',
      'organization' => 'Google Inc.',
      'given_name' => 'John',
      'family_name' => 'Smith',
    ],
  ]);
  $this->defaultProfile
    ->save();
  $this->defaultProfile = $this
    ->reloadEntity($this->defaultProfile);
  $this->orderProfile = Profile::create([
    'type' => 'customer',
    'uid' => 0,
    'address' => [
      'country_code' => 'US',
      'postal_code' => '53177',
      'locality' => 'Milwaukee',
      'address_line1' => 'Pabst Blue Ribbon Dr',
      'administrative_area' => 'WI',
      'given_name' => 'Frederick',
      'family_name' => 'Pabst',
    ],
    'data' => [
      'copy_to_address_book' => TRUE,
    ],
  ]);
  $this->orderProfile
    ->save();
  $this->orderProfile = $this
    ->reloadEntity($this->orderProfile);
}