public function WorkspaceAccessTest::testPublishWorkspaceAccess in Drupal 9
Same name and namespace in other branches
- 8 core/modules/workspaces/tests/src/Kernel/WorkspaceAccessTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceAccessTest::testPublishWorkspaceAccess()
- 10 core/modules/workspaces/tests/src/Kernel/WorkspaceAccessTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceAccessTest::testPublishWorkspaceAccess()
Tests workspace publishing access.
File
- core/
modules/ workspaces/ tests/ src/ Kernel/ WorkspaceAccessTest.php, line 96
Class
- WorkspaceAccessTest
- Tests access on workspaces.
Namespace
Drupal\Tests\workspaces\KernelCode
public function testPublishWorkspaceAccess() {
$user = $this
->createUser([
'view own workspace',
'edit own workspace',
]);
$this
->setCurrentUser($user);
$workspace = Workspace::create([
'id' => 'stage',
]);
$workspace
->save();
// Check that, by default, an admin user is allowed to publish a workspace.
$workspace
->publish();
// Simulate an external factor which decides that a workspace can not be
// published.
\Drupal::state()
->set('workspace_access_test.result.publish', AccessResult::forbidden());
\Drupal::entityTypeManager()
->getAccessControlHandler('workspace')
->resetCache();
$this
->expectException(WorkspaceAccessException::class);
$workspace
->publish();
}