You are here

public function GroupContentCreateAccessTest::testPageAccess in Group 2.0.x

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

Tests access to the create/add overview page.

@dataProvider pageAccessProvider

File

tests/src/Kernel/GroupContentCreateAccessTest.php, line 89

Class

GroupContentCreateAccessTest
Tests the group content create access for groups.

Namespace

Drupal\Tests\group\Kernel

Code

public function testPageAccess($route, $outsider_permissions, $member_permissions, $outsider_access, $member_access, $admin_access, $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(),
    ],
  ]);
  $request = $this
    ->createRequest($route, $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);
}