function WorkspacePermissionsTest::testDeleteAnyWorkspace
Verifies that a user can delete any workspace.
File
- 
              core/
modules/ workspaces/ tests/ src/ Functional/ WorkspacePermissionsTest.php, line 181  
Class
- WorkspacePermissionsTest
 - Tests permission controls on workspaces.
 
Namespace
Drupal\Tests\workspaces\FunctionalCode
public function testDeleteAnyWorkspace() : void {
  $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/workspaces/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/workspaces/manage/{$packers->id()}/delete");
  $this->assertSession()
    ->statusCodeEquals(200);
  $this->drupalGet("/admin/config/workflow/workspaces/manage/{$bears->id()}/delete");
  $this->assertSession()
    ->statusCodeEquals(200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.