You are here

public function RouterPermissionTest::testPermissionAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Routing/RouterPermissionTest.php \Drupal\system\Tests\Routing\RouterPermissionTest::testPermissionAccess()

Tests permission requirements on routes.

File

core/modules/system/src/Tests/Routing/RouterPermissionTest.php, line 29
Contains \Drupal\system\Tests\Routing\RouterPermissionTest.

Class

RouterPermissionTest
Function Tests for the routing permission system.

Namespace

Drupal\system\Tests\Routing

Code

public function testPermissionAccess() {
  $path = 'router_test/test7';
  $this
    ->drupalGet($path);
  $this
    ->assertResponse(403, "Access denied for a route where we don't have a permission");
  $this
    ->drupalGet('router_test/test8');
  $this
    ->assertResponse(403, 'Access denied by default if no access specified');
  $user = $this
    ->drupalCreateUser(array(
    'access test7',
  ));
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('router_test/test7');
  $this
    ->assertResponse(200);
  $this
    ->assertNoRaw('Access denied');
  $this
    ->assertRaw('test7text', 'The correct string was returned because the route was successful.');
}