You are here

public function ChecklistapiTest::testChecklistAccess in Checklist API 8

Tests checklist access.

Throws

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Functional/ChecklistapiTest.php, line 62

Class

ChecklistapiTest
Functionally tests Checklist API.

Namespace

Drupal\Tests\checklistapi\Functional

Code

public function testChecklistAccess() {

  // Assert that access is granted to a user with "edit any checklistapi
  // checklist" permission.
  $this
    ->drupalGet('admin/config/development/checklistapi-example');
  $this
    ->assertResponse(200);

  // Assert that access is granted to a user with checklist-specific
  // permission.
  $permissions = [
    'edit example_checklist checklistapi checklist',
  ];
  $semi_privileged_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($semi_privileged_user);
  $this
    ->drupalGet('admin/config/development/checklistapi-example');
  $this
    ->assertResponse(200);

  // Assert that access is denied to a non-privileged user.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('admin/config/development/checklistapi-example');
  $this
    ->assertResponse(403);
}