function WorkspaceAccessTest::testPublishWorkspaceAccess
Same name in other branches
- 9 core/modules/workspaces/tests/src/Kernel/WorkspaceAccessTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceAccessTest::testPublishWorkspaceAccess()
- 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceAccessTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceAccessTest::testPublishWorkspaceAccess()
- 11.x 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() : void {
$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.
$this->assertTrue($workspace->access('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->assertFalse($workspace->access('publish'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.