function MenuActiveTrailTest::testGetCid
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetCid()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetCid()
- 11.x core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetCid()
Tests getCid()
@covers ::getCid
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ MenuActiveTrailTest.php, line 198
Class
- MenuActiveTrailTest
- Tests the active menu trail service.
Namespace
Drupal\Tests\Core\MenuCode
public function testGetCid() : void {
$data = $this->provider()[1];
/** @var \Symfony\Component\HttpFoundation\Request $request */
$request = $data[0];
/** @var \Symfony\Component\Routing\Route $route */
$route = $request->attributes
->get(RouteObjectInterface::ROUTE_OBJECT);
$route->setPath('/test/{b}/{a}');
$request->attributes
->get('_raw_variables')
->add([
'b' => 1,
'a' => 0,
]);
$this->requestStack
->push($request);
$this->menuLinkManager
->expects($this->any())
->method('loadLinksByRoute')
->with('baby_llama')
->willReturn($data[1]);
$expected_link = $data[3];
$expected_trail = $data[4];
$expected_trail_ids = array_combine($expected_trail, $expected_trail);
$this->menuLinkManager
->expects($this->any())
->method('getParentIds')
->willReturnMap([
[
$expected_link->getPluginId(),
$expected_trail_ids,
],
]);
$this->assertSame($expected_trail_ids, $this->menuActiveTrail
->getActiveTrailIds($data[2]));
$this->cache
->expects($this->once())
->method('set')
->with('active-trail:route:baby_llama:route_parameters:' . serialize([
'a' => 0,
'b' => 1,
]));
$this->lock
->expects($this->any())
->method('acquire')
->willReturn(TRUE);
$this->menuActiveTrail
->destruct();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.