public function AddressBookTest::testFallback in Commerce Core 8.2
Tests the fallback to the default profile UI.
When there's only one profile type, and it only allows one profile per customer, the address book should not be available, and profile module's default UI should be used instead.
File
- modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php, line 249
Class
- AddressBookTest
- Tests the address book pages.
Namespace
Drupal\Tests\commerce_order\FunctionalJavascriptCode
public function testFallback() {
$profile = ProfileType::load('customer');
$profile
->setMultiple(FALSE);
$profile
->save();
\Drupal::service('router.builder')
->rebuild();
$customer = $this
->createUser([
'access user profiles',
'view own customer profile',
'update own customer profile',
]);
$profile = $this
->createEntity('profile', [
'type' => 'customer',
'uid' => $customer
->id(),
'address' => $this->firstAddress,
]);
$this
->drupalLogin($customer);
$this
->drupalGet(Url::fromRoute('commerce_order.address_book.overview', [
'user' => $customer
->id(),
]));
$this
->assertSession()
->pageTextContains('Access Denied');
$this
->drupalGet($customer
->toUrl());
$this
->assertSession()
->linkNotExists('Address book');
// The local task provided by profile module should be visible.
$this
->assertSession()
->linkExists('Customer information');
$this
->getSession()
->getPage()
->clickLink('Customer information');
$this
->saveHtmlOutput();
// Confirm that the profile can be updated.
foreach ($this->firstAddress as $property => $value) {
$this
->assertSession()
->fieldValueEquals("address[0][address][{$property}]", $value);
}
$this
->submitForm([
'address[0][address][address_line1]' => '10 Drupal Ave',
], 'Save');
$this
->assertSession()
->pageTextContains('The profile has been saved.');
/** @var \Drupal\profile\Entity\ProfileInterface $profile */
$profile = $this
->reloadEntity($profile);
$this
->assertEquals('10 Drupal Ave', $profile
->get('address')->address_line1);
}