public function WorkspacePermissionsTest::testDeleteAnyWorkspace in Workspace 8.2
Verifies that a user can delete any workspace.
File
- tests/
src/ Functional/ WorkspacePermissionsTest.php, line 173
Class
- WorkspacePermissionsTest
- Tests permission controls on workspaces.
Namespace
Drupal\Tests\workspace\FunctionalCode
public function testDeleteAnyWorkspace() {
$permissions = [
'access administration pages',
'administer site configuration',
'create workspace',
'delete own workspace',
];
$editor1 = $this
->drupalCreateUser($permissions);
// Login as a limited-access user and create a workspace.
$this
->drupalLogin($editor1);
$bears = $this
->createWorkspaceThroughUi('Bears', 'bears');
// Now edit that same workspace; We should be able to do so.
$this
->drupalGet("/admin/config/workflow/workspace/manage/{$bears->id()}/delete");
$this
->assertSession()
->statusCodeEquals(200);
// Now login as a different user and ensure they have delete access on both
// workspaces.
$admin = $this
->drupalCreateUser(array_merge($permissions, [
'delete any workspace',
]));
$this
->drupalLogin($admin);
$packers = $this
->createWorkspaceThroughUi('Packers', 'packers');
$this
->drupalGet("/admin/config/workflow/workspace/manage/{$packers->id()}/delete");
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet("/admin/config/workflow/workspace/manage/{$bears->id()}/delete");
$this
->assertSession()
->statusCodeEquals(200);
// Check that the default workspace can not be deleted, even by a user with
// the "delete any workspace" permission.
$this
->drupalGet("/admin/config/workflow/workspace/manage/live/delete");
$this
->assertSession()
->statusCodeEquals(403);
}