You are here

public function DuplicateRoleTest::testDuplicateRolePermissions in Duplicate role 8

Tests module permission, links visibility, and page access.

File

tests/src/Functional/DuplicateRoleTest.php, line 36

Class

DuplicateRoleTest
Functional tests for Duplicate Role module.

Namespace

Drupal\Tests\duplicate_role\Functional

Code

public function testDuplicateRolePermissions() {
  $this
    ->drupalLogin($this
    ->createUser([
    'administer permissions',
  ]));
  $this
    ->drupalGet('/admin/people/roles');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Duplicate role links should not be visible.
  $this
    ->assertSession()
    ->linkNotExists('Duplicate role');
  $this
    ->assertSession()
    ->linkNotExists('Duplicate');

  // Page should not be accessible.
  $this
    ->drupalGet('/admin/people/roles/duplicate');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogin($this
    ->createUser([
    'administer permissions',
    'administer duplicate role',
  ]));
  $this
    ->drupalGet('/admin/people/roles');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Duplicate role links should be visible and pages should be accessible.
  $this
    ->assertSession()
    ->linkExists('Duplicate role');
  $this
    ->assertSession()
    ->linkExists('Duplicate');
  $this
    ->drupalGet('/admin/people/roles/duplicate');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}