You are here

public function ProtectedPagesAccess::testProtectedPageConfigurationAccess in Protected Pages 8

Test access to Protected Pages Configuration screen.

File

tests/src/Functional/ProtectedPagesAccess.php, line 94

Class

ProtectedPagesAccess
Provides functional Drupal tests for access to protected pages and config.

Namespace

Drupal\Tests\protected_pages\Functional

Code

public function testProtectedPageConfigurationAccess() {

  // Create a user w/ permission
  // to 'administer protected pages configuration'.
  $adminUser = $this
    ->drupalCreateUser([
    'administer protected pages configuration',
  ]);

  // Create a user w/ permission
  // to 'access protected page password screen'.
  $user = $this
    ->drupalCreateUser([
    'access protected page password screen',
  ]);

  // Test access to Protected Pages Configuration screen.
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('admin/config/system/protected_pages');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogout($user);
  $this
    ->drupalLogin($adminUser);
  $this
    ->drupalGet('admin/config/system/protected_pages');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalLogout($adminUser);
}