function MenuActiveTrailTest::testGetActiveTrailIds
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveTrailIds()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveTrailIds()
- 11.x core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveTrailIds()
Tests getActiveTrailIds().
@covers ::getActiveTrailIds @dataProvider provider
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ MenuActiveTrailTest.php, line 165
Class
- MenuActiveTrailTest
- Tests the active menu trail service.
Namespace
Drupal\Tests\Core\MenuCode
public function testGetActiveTrailIds(Request $request, $links, $menu_name, $expected_link, $expected_trail) : void {
$expected_trail_ids = array_combine($expected_trail, $expected_trail);
$this->requestStack
->push($request);
if ($links !== FALSE) {
// We expect exactly two calls, one for the first call, and one after the
// cache clearing below.
$this->menuLinkManager
->expects($this->exactly(2))
->method('loadLinksByRoute')
->with('baby_llama')
->willReturn($links);
if ($expected_link !== NULL) {
$this->menuLinkManager
->expects($this->exactly(2))
->method('getParentIds')
->willReturnMap([
[
$expected_link->getPluginId(),
$expected_trail_ids,
],
]);
}
}
// Call out the same twice in order to ensure that static caching works.
$this->assertSame($expected_trail_ids, $this->menuActiveTrail
->getActiveTrailIds($menu_name));
$this->assertSame($expected_trail_ids, $this->menuActiveTrail
->getActiveTrailIds($menu_name));
$this->menuActiveTrail
->clear();
$this->assertSame($expected_trail_ids, $this->menuActiveTrail
->getActiveTrailIds($menu_name));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.