public function WorkspaceIndividualPermissionsTest::testEditIndividualWorkspace in Workspace 8
Verifies that a user can create and edit only their own workspace.
File
- tests/
src/ Functional/ WorkspaceIndividualPermissionsTest.php, line 26
Class
- WorkspaceIndividualPermissionsTest
- Tests permission controls on workspaces.
Namespace
Drupal\Tests\workspace\FunctionalCode
public function testEditIndividualWorkspace() {
$permissions = [
'access administration pages',
'administer site configuration',
'create_workspace',
'edit_own_workspace',
'view_own_workspace',
];
$editor1 = $this
->drupalCreateUser($permissions);
// Login as a limited-access user and create a workspace.
$this
->drupalLogin($editor1);
$this
->createWorkspaceThroughUI('Bears', 'bears');
$bears = $this
->getOneWorkspaceByLabel('Bears');
// Now login as a different user with permission to edit that workspace,
// specifically.
$editor2 = $this
->drupalCreateUser(array_merge($permissions, [
'update_workspace_' . $bears
->id(),
]));
$this
->drupalLogin($editor2);
$session = $this
->getSession();
$this
->drupalGet("/admin/structure/workspace/{$bears->id()}/edit");
$this
->assertEquals(200, $session
->getStatusCode());
}