function MenuActiveTrail403Test::testMenuActiveTrail403Cache

Same name in other branches
  1. 10 core/tests/Drupal/FunctionalTests/Menu/MenuActiveTrail403Test.php \Drupal\FunctionalTests\Menu\MenuActiveTrail403Test::testMenuActiveTrail403Cache()
  2. 11.x core/tests/Drupal/FunctionalTests/Menu/MenuActiveTrail403Test.php \Drupal\FunctionalTests\Menu\MenuActiveTrail403Test::testMenuActiveTrail403Cache()

Tests that visiting 403 page does not override original active trail.

File

core/tests/Drupal/FunctionalTests/Menu/MenuActiveTrail403Test.php, line 87

Class

MenuActiveTrail403Test
Tests that 403 active trail behavior does not overwrite original entry.

Namespace

Drupal\FunctionalTests\Menu

Code

public function testMenuActiveTrail403Cache() {
    $this->drupalLogin($this->privilegedUser);
    $system_status_url = Url::fromRoute('system.status');
    $this->drupalGet($system_status_url);
    // Check status code.
    $this->assertSession()
        ->statusCodeEquals(200);
    // Check that our menu item to the status page is there.
    $this->assertSession()
        ->pageTextContains('Link to Status page');
    $this->drupalLogout();
    // Visit the same page as anonymous.
    $this->drupalGet($system_status_url);
    // Check that the anonymous user gets a 403 page.
    $this->assertSession()
        ->statusCodeEquals(403);
    // Visit the page again as privileged user. And check that the menu is still
    // printed.
    $this->drupalLogin($this->privilegedUser);
    $system_status_url = Url::fromRoute('system.status');
    $this->drupalGet($system_status_url);
    // Check status code.
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('Link to Status page');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.