function BookBreadcrumbTest::testBreadcrumbAccessUpdates
Same name in other branches
- 9 core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::testBreadcrumbAccessUpdates()
- 10 core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::testBreadcrumbAccessUpdates()
- 11.x core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::testBreadcrumbAccessUpdates()
Test that the breadcrumb is updated when book access changes.
File
-
core/
modules/ book/ tests/ src/ Functional/ BookBreadcrumbTest.php, line 195
Class
- BookBreadcrumbTest
- Create a book, add pages, and test book interface.
Namespace
Drupal\Tests\book\FunctionalCode
public function testBreadcrumbAccessUpdates() {
// Create a new book.
$nodes = $this->createBreadcrumbBook();
$this->drupalLogin($this->bookAuthor);
$edit = [
'title[0][value]' => "you can't see me",
];
$this->drupalPostForm($nodes[3]->toUrl('edit-form'), $edit, 'Save');
$this->drupalGet($nodes[4]->toUrl());
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
$got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = $link->getText();
}
$this->assertCount(5, $got_breadcrumb);
$this->assertEqual($edit['title[0][value]'], end($got_breadcrumb));
$config = $this->container
->get('config.factory')
->getEditable('book_breadcrumb_test.settings');
$config->set('hide', TRUE)
->save();
$this->drupalGet($nodes[4]->toUrl());
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
$got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = $link->getText();
}
$this->assertCount(4, $got_breadcrumb);
$this->assertEqual($nodes[2]->getTitle(), end($got_breadcrumb));
$this->drupalGet($nodes[3]->toUrl());
$this->assertSession()
->statusCodeEquals(403);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.