public function RevisionUiAccessTest::testViewAccess in Group 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/RevisionUiAccessTest.php \Drupal\Tests\group\Kernel\RevisionUiAccessTest::testViewAccess()
Tests access to the view page.
@dataProvider viewAccessProvider
File
- tests/
src/ Kernel/ RevisionUiAccessTest.php, line 190
Class
- RevisionUiAccessTest
- Tests the revision UI access for groups.
Namespace
Drupal\Tests\group\KernelCode
public function testViewAccess($outsider_permissions, $member_permissions, $outsider_access, $member_access, $admin_access, $new_revision, $extra_revision, $pass_default_revision, $revision_published, $extra_revision_published, $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(),
'status' => $revision_published,
]);
$group
->addMember($member);
$group
->addMember($admin, [
'group_roles' => [
$this->adminRole
->id(),
],
]);
$group_revision = clone $group;
if ($extra_revision) {
if ($extra_revision_published) {
$group_revision
->setPublished();
}
else {
$group_revision
->setUnpublished();
}
$group_revision
->setNewRevision(TRUE);
$group_revision
->isDefaultRevision(TRUE);
$group_revision
->save();
if (!$pass_default_revision) {
$group_revision = $group;
}
}
if (!$new_revision) {
$this->groupType
->set('new_revision', $new_revision)
->save();
}
$request = $this
->createRequest('entity.group.revision', $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);
}