protected function MenuTrailByPathActiveTrailHtmlClassTest::setUp in Menu Trail By Path 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ MenuTrailByPathActiveTrailHtmlClassTest.php, line 55
Class
- MenuTrailByPathActiveTrailHtmlClassTest
- Tests that the menu links have the correct css-classes.
Namespace
Drupal\Tests\menu_trail_by_path\FunctionalCode
protected function setUp() {
parent::setUp();
// Create user
$this->authenticatedUser = $this
->drupalCreateUser();
// Create content type
$this
->drupalCreateContentType(array(
'type' => 'page',
'name' => 'Basic page',
));
// Create nodes
$node1 = $this
->drupalCreateNode();
$this
->createPathAlias('/node/' . $node1
->id(), '/news');
$node2 = $this
->drupalCreateNode();
$this
->createPathAlias('/node/' . $node2
->id(), '/news/category-a');
// Set menuUrls
$this->menuUrls = [
'Home' => Url::fromUri('route:<front>'),
'User password' => Url::fromUri('route:user.pass'),
'User login' => Url::fromUri('route:user.login'),
'User' => Url::fromUri('route:user.page'),
'News' => Url::fromUri('route:entity.node.canonical;node=' . $node1
->id()),
'News » News overview' => Url::fromUri('route:entity.node.canonical;node=' . $node1
->id()),
'News » Category A' => Url::fromUri('route:entity.node.canonical;node=' . $node2
->id()),
];
// Build the main menu.
$this
->buildMenu();
$this
->drupalPlaceBlock('system_menu_block:main', [
'id' => 'system-menu-block-main',
'label' => 'Main menu',
'region' => 'header',
]);
}