You are here

public function RevisionUiAccessTest::testOverviewAccess in Group 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/RevisionUiAccessTest.php \Drupal\Tests\group\Kernel\RevisionUiAccessTest::testOverviewAccess()

Tests access to the overview page.

@dataProvider overviewAccessProvider

File

tests/src/Kernel/RevisionUiAccessTest.php, line 75

Class

RevisionUiAccessTest
Tests the revision UI access for groups.

Namespace

Drupal\Tests\group\Kernel

Code

public function testOverviewAccess($outsider_permissions, $member_permissions, $outsider_access, $member_access, $admin_access, $new_revision, $extra_revision, $message) {
  $outsider = $this
    ->createUser();
  $member = $this
    ->createUser();
  $admin = $this
    ->createUser();
  $this->groupType
    ->getOutsiderRole()
    ->grantPermissions($outsider_permissions)
    ->save();
  $this->groupType
    ->getMemberRole()
    ->grantPermissions($member_permissions)
    ->save();
  $group = $this
    ->createGroup([
    'type' => $this->groupType
      ->id(),
  ]);
  $group
    ->addMember($member);
  $group
    ->addMember($admin, [
    'group_roles' => [
      $this->adminRole
        ->id(),
    ],
  ]);
  if ($extra_revision) {
    $group
      ->setNewRevision(TRUE);
    $group
      ->isDefaultRevision(TRUE);
    $group
      ->save();
  }
  if (!$new_revision) {
    $this->groupType
      ->set('new_revision', $new_revision)
      ->save();
  }
  $request = $this
    ->createRequest('entity.group.version_history', $this
    ->reloadEntity($group));
  $this
    ->assertSame($outsider_access, $this->accessManager
    ->checkRequest($request, $outsider), $message);
  $this
    ->assertSame($member_access, $this->accessManager
    ->checkRequest($request, $member), $message);
  $this
    ->assertSame($admin_access, $this->accessManager
    ->checkRequest($request, $admin), $message);
}