You are here

protected function MenuPerRoleAccessTest::linksAccessTest in Menu Per Role 8

Test if the users can see the expected links.

Throws

\Behat\Mink\Exception\ExpectationException

3 calls to MenuPerRoleAccessTest::linksAccessTest()
MenuPerRoleAccessTest::testAdminBypass in tests/src/Functional/MenuPerRoleAccessTest.php
Check the admin bypass feature in front.
MenuPerRoleAccessTest::testRoleAccess in tests/src/Functional/MenuPerRoleAccessTest.php
Check if users have access to menu links.
MenuPerRoleAdminAccessTest::testRoleAccess in tests/src/Functional/MenuPerRoleAdminAccessTest.php
Check if users have access to menu links.

File

tests/src/Functional/MenuPerRoleAccessTest.php, line 493

Class

MenuPerRoleAccessTest
Test access control to menu links.

Namespace

Drupal\Tests\menu_per_role\Functional

Code

protected function linksAccessTest() : void {
  foreach ($this->expectations as $userProperty => $expectations) {
    if ($userProperty == 'anonymous') {
      $this
        ->drupalLogout();
    }
    else {
      $this
        ->drupalLogin($this->{$userProperty});
    }
    $this
      ->drupalGet($this->testPath);
    foreach ($expectations as $label => $expectation) {
      if ($expectation) {
        $this
          ->assertSession()
          ->linkExists($label);
      }
      else {
        $this
          ->assertSession()
          ->linkNotExists($label);
      }
    }
  }
}