public function WorkspaceAccessTest::testWorkspaceAccess in Drupal 9
Same name and namespace in other branches
- 8 core/modules/workspaces/tests/src/Kernel/WorkspaceAccessTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceAccessTest::testWorkspaceAccess()
- 10 core/modules/workspaces/tests/src/Kernel/WorkspaceAccessTest.php \Drupal\Tests\workspaces\Kernel\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));
}