function DefaultMenuLinkTreeManipulatorsTest::testCheckAccessWithLinkToAnyPagePermission
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest::testCheckAccessWithLinkToAnyPagePermission()
Tests checkAccess() tree manipulator with 'link to any page' permission.
@covers ::checkAccess @covers ::menuLinkCheckAccess
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ DefaultMenuLinkTreeManipulatorsTest.php, line 251
Class
- DefaultMenuLinkTreeManipulatorsTest
- Tests the default menu link tree manipulators.
Namespace
Drupal\Tests\Core\MenuCode
public function testCheckAccessWithLinkToAnyPagePermission() {
$this->mockTree();
$this->currentUser
->expects($this->exactly(9))
->method('hasPermission')
->with('link to any page')
->willReturn(TRUE);
$this->mockTree();
$this->cacheContextManager
->assertValidTokens([
'user.permissions',
])
->shouldBeCalled()
->willReturn(TRUE);
$this->defaultMenuTreeManipulators
->checkAccess($this->originalTree);
$expected_access_result = AccessResult::allowed()->cachePerPermissions();
$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.