public function WorkspaceViewTest::testViewAnyWorkspace in Workspace 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/WorkspaceViewTest.php \Drupal\Tests\workspace\Functional\WorkspaceViewTest::testViewAnyWorkspace()
Verifies that a user can view any workspace.
File
- tests/
src/ Functional/ WorkspaceViewTest.php, line 63
Class
- WorkspaceViewTest
- Tests permission controls on workspaces.
Namespace
Drupal\Tests\workspace\FunctionalCode
public function testViewAnyWorkspace() {
$permissions = [
'access administration pages',
'administer site configuration',
'create workspace',
'edit own workspace',
'view any workspace',
];
$editor1 = $this
->drupalCreateUser($permissions);
// Login as a limited-access user and create a workspace.
$this
->drupalLogin($editor1);
$this
->createWorkspaceThroughUi('Bears', 'bears');
$bears = Workspace::load('bears');
// Now login as a different user and create a workspace.
$editor2 = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($editor2);
$this
->createWorkspaceThroughUi('Packers', 'packers');
$packers = Workspace::load('packers');
// Load the activate form for the Bears workspace. This user should be
// able to see both workspaces because of the "view any" permission.
$this
->drupalGet("admin/config/workflow/workspace/manage/{$bears->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
// But editor 2 should be able to activate the Packers workspace.
$this
->drupalGet("admin/config/workflow/workspace/manage/{$packers->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
}