public function MenuBlockTitleTest::testSecondLevel in Menu block title 8
Tests that viewing a node that is a child of menu item shows the parent as a link as the title of the menu block.
File
- tests/
src/ Functional/ MenuBlockTitleTest.php, line 73
Class
- MenuBlockTitleTest
- Class SettingsPageTest.
Namespace
Drupal\Tests\menu_block_title\FunctionalCode
public function testSecondLevel() {
$href = '/node/1';
$this
->drupalGet('/node/2');
$this
->assertSession()
->elementContains('css', 'h2#block-sidebar-nav-main-menu', 'Test page title for top level nav');
$xpath = $this
->assertSession()
->buildXPathQuery('//h2[@id="block-sidebar-nav-main-menu"]/a[contains(@href, :href)]', [
':href' => $href,
]);
$link = $this
->getSession()
->getPage()
->findAll('xpath', $xpath);
$message = strtr('Link containing href %href found.', [
'%href' => $href,
]);
$this
->assertSession()
->assert(!empty($link), $message);
}