function DefaultMenuLinkTreeManipulatorsTest::testCheckAccessTreeManipulator
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest::testCheckAccessTreeManipulator()
Tests checkAccess() tree manipulator.
@covers ::checkAccess @covers ::menuLinkCheckAccess
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ DefaultMenuLinkTreeManipulatorsTest.php, line 257
Class
- DefaultMenuLinkTreeManipulatorsTest
- Tests the default menu link tree manipulators.
Namespace
Drupal\Tests\Core\MenuCode
public function testCheckAccessTreeManipulator() : void {
$this->mockTree();
// There are 9 checks but one is on an external link, so the route access
// checker should be called only 8 times.
// @see \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::menuLinkCheckAccess()
$this->accessManager
->expects($this->exactly(8))
->method('checkNamedRoute')
->willReturn(AccessResult::allowed());
$this->mockTree();
$this->defaultMenuTreeManipulators
->checkAccess($this->originalTree);
$expected_access_result = AccessResult::allowed();
$this->assertEquals($expected_access_result, $this->originalTree[1]->access);
$this->assertEquals($expected_access_result, $this->originalTree[2]->access);
$this->assertEquals($expected_access_result, $this->originalTree[2]->subtree[3]->access);
$this->assertEquals($expected_access_result, $this->originalTree[2]->subtree[3]->subtree[4]->access);
$this->assertEquals($expected_access_result, $this->originalTree[5]->subtree[7]->access);
$this->assertEquals($expected_access_result, $this->originalTree[6]->access);
$this->assertEquals($expected_access_result, $this->originalTree[8]->access);
$this->assertEquals($expected_access_result, $this->originalTree[9]->access);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.