public function AddressBookTest::testOverviewAccess in Commerce Core 8.2
Tests the overview access checking.
File
- modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php, line 109
Class
- AddressBookTest
- Tests the address book pages.
Namespace
Drupal\Tests\commerce_order\FunctionalJavascriptCode
public function testOverviewAccess() {
// Confirm that the anonymous user doesn't have an address book.
$this
->drupalGet('user/0/address-book');
$this
->drupalGet(Url::fromRoute('commerce_order.address_book.overview', [
'user' => 0,
]));
$this
->assertSession()
->pageTextContains('Access Denied');
// Confirm that no address book is available when the user can't view
// the user's canonical page ("/user/{user}").
$customer = $this
->createUser([
'view any customer profile',
]);
$this
->drupalLogin($customer);
$this
->drupalGet($this->adminUser
->toUrl('canonical'));
$this
->assertSession()
->pageTextContains('Access denied');
$this
->drupalGet(Url::fromRoute('commerce_order.address_book.overview', [
'user' => $this->adminUser
->id(),
]));
$this
->assertSession()
->pageTextContains('Access Denied');
// Confirm that no address book is available when the user can't view
// any profile types.
$customer = $this
->createUser([
'access user profiles',
]);
$this
->drupalLogin($customer);
$this
->drupalGet($this->adminUser
->toUrl('canonical'));
$this
->assertSession()
->pageTextNotContains('Access denied');
$this
->drupalGet(Url::fromRoute('commerce_order.address_book.overview', [
'user' => $this->adminUser
->id(),
]));
$this
->assertSession()
->pageTextContains('Access Denied');
// Confirm that the address book is visible when the user can view
// at least one profile type.
$customer = $this
->createUser([
'access user profiles',
'view any customer profile',
]);
$this
->createEntity('profile', [
'type' => 'customer',
'uid' => $this->adminUser
->id(),
'address' => $this->secondAddress,
]);
$this
->drupalLogin($customer);
$this
->drupalGet($this->adminUser
->toUrl('canonical'));
$this
->assertSession()
->pageTextNotContains('Access denied');
$this
->drupalGet(Url::fromRoute('commerce_order.address_book.overview', [
'user' => $this->adminUser
->id(),
]));
$this
->assertSession()
->pageTextNotContains('Access Denied');
$this
->assertSession()
->pageTextContains('1098 Alta Ave');
// Confirm that the local task is present.
$this
->assertSession()
->linkExists('Address book');
$this
->assertSession()
->linkNotExists('Billing information');
}