You are here

public function DefaultMenuLinkTreeManipulatorsTest::testCheckAccessWithLinkToAnyPagePermission in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 237
Contains \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest.

Class

DefaultMenuLinkTreeManipulatorsTest
Tests the default menu link tree manipulators.

Namespace

Drupal\Tests\Core\Menu

Code

public function testCheckAccessWithLinkToAnyPagePermission() {
  $this
    ->mockTree();
  $this->currentUser
    ->expects($this
    ->exactly(9))
    ->method('hasPermission')
    ->with('link to any page')
    ->willReturn(TRUE);
  $this
    ->mockTree();
  $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);
}