function BookBreadcrumbTest::testBreadcrumbTitleUpdates
Same name in other branches
- 9 core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::testBreadcrumbTitleUpdates()
- 8.9.x core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::testBreadcrumbTitleUpdates()
- 11.x core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::testBreadcrumbTitleUpdates()
Tests that the breadcrumb is updated when book content changes.
File
-
core/
modules/ book/ tests/ src/ Functional/ BookBreadcrumbTest.php, line 153
Class
- BookBreadcrumbTest
- Create a book, add pages, and test book interface.
Namespace
Drupal\Tests\book\FunctionalCode
public function testBreadcrumbTitleUpdates() : void {
// Create a new book.
$nodes = $this->createBreadcrumbBook();
$book = $this->book;
$this->drupalLogin($this->bookAuthor);
$this->drupalGet($nodes[4]->toUrl());
// Fetch each node title in the current breadcrumb.
$links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
$got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = $link->getText();
}
// Home link and four parent book nodes should be in the breadcrumb.
$this->assertCount(5, $got_breadcrumb);
$this->assertEquals($nodes[3]->getTitle(), end($got_breadcrumb));
$edit = [
'title[0][value]' => 'Updated node5 title',
];
$this->drupalGet($nodes[3]->toUrl('edit-form'));
$this->submitForm($edit, 'Save');
$this->drupalGet($nodes[4]->toUrl());
// Fetch each node title in the current breadcrumb.
$links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
$got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = $link->getText();
}
$this->assertCount(5, $got_breadcrumb);
$this->assertEquals($edit['title[0][value]'], end($got_breadcrumb));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.