function MenuActiveTrailTest::testGetActiveTrailIds
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveTrailIds()
- 10 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 162
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) {
$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')
->will($this->returnValue($links));
if ($expected_link !== NULL) {
$this->menuLinkManager
->expects($this->exactly(2))
->method('getParentIds')
->will($this->returnValueMap([
[
$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.