public function AddressBookTest::testLoadProfiles in Commerce Core 8.2
@covers ::loadAll @covers ::load
File
- modules/
order/ tests/ src/ Kernel/ AddressBookTest.php, line 159
Class
- AddressBookTest
- Tests the address book.
Namespace
Drupal\Tests\commerce_order\KernelCode
public function testLoadProfiles() {
$second_profile = Profile::create([
'type' => 'customer',
'uid' => $this->user
->id(),
'address' => [
'country_code' => 'RS',
'postal_code' => '11000',
'locality' => 'Belgrade',
'address_line1' => 'Cetinjska 15',
'given_name' => 'John',
'family_name' => 'Smith',
],
]);
$second_profile
->save();
$second_profile = $this
->reloadEntity($second_profile);
$this
->assertEquals([
3 => $second_profile,
1 => $this->defaultProfile,
], $this->addressBook
->loadAll($this->user, 'customer'));
$this
->assertEquals([
1 => $this->defaultProfile,
], $this->addressBook
->loadAll($this->user, 'customer', [
'US',
]));
$this
->assertEquals([
3 => $second_profile,
], $this->addressBook
->loadAll($this->user, 'customer', [
'RS',
]));
$this
->assertEquals($this->defaultProfile, $this->addressBook
->load($this->user, 'customer'));
$this
->assertNull($this->addressBook
->load($this->user, 'customer', [
'RS',
]));
}