You are here

public function WorkspaceAccessTest::testWorkspaceAccess in Workspace 8.2

Verifies all workspace roles have the correct access for the operation.

@dataProvider operationCases

Parameters

string $operation: The operation to test with.

string $permission: The permission to test with.

File

tests/src/Kernel/WorkspaceAccessTest.php, line 71

Class

WorkspaceAccessTest
Tests access on workspaces.

Namespace

Drupal\Tests\workspace\Kernel

Code

public function testWorkspaceAccess($operation, $permission) {
  $user = $this
    ->createUser();
  $this
    ->setCurrentUser($user);
  $workspace = Workspace::create([
    'id' => 'oak',
  ]);
  $workspace
    ->save();
  $this
    ->assertFalse($workspace
    ->access($operation, $user));
  \Drupal::entityTypeManager()
    ->getAccessControlHandler('workspace')
    ->resetCache();
  $role = $this
    ->createRole([
    $permission,
  ]);
  $user
    ->addRole($role);
  $this
    ->assertTrue($workspace
    ->access($operation, $user));
}