You are here

public function RevisionUiAccessTest::testUpdateDeleteAccess in Group 2.0.x

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

Tests access to the update (revert) or delete form.

@dataProvider updateDeleteAccessProvider

File

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

Class

RevisionUiAccessTest
Tests the revision UI access for groups.

Namespace

Drupal\Tests\group\Kernel

Code

public function testUpdateDeleteAccess($route_name, $outsider_permissions, $member_permissions, $outsider_access, $member_access, $admin_access, $pass_default_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(),
    ],
  ]);
  $group_revision = clone $group;
  $group_revision
    ->setNewRevision(TRUE);
  $group_revision
    ->isDefaultRevision(TRUE);
  $group_revision
    ->save();
  if (!$pass_default_revision) {
    $group_revision = $group;
  }
  $request = $this
    ->createRequest($route_name, $this
    ->reloadEntity($group), $this
    ->reloadRevision($group_revision));
  $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);
}