function WorkspaceAccessTest::testWorkspaceAccess
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
- 
              core/modules/ workspaces/ tests/ src/ Kernel/ WorkspaceAccessTest.php, line 79 
Class
- WorkspaceAccessTest
- Tests access on workspaces.
Namespace
Drupal\Tests\workspaces\KernelCode
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));
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
