function WorkspaceTest::testDeleteWorkspaceWithExistingContent

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testDeleteWorkspaceWithExistingContent()
  2. 11.x core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testDeleteWorkspaceWithExistingContent()

Verifies that a workspace with existing content may be deleted.

File

core/modules/workspaces/tests/src/Functional/WorkspaceTest.php, line 271

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testDeleteWorkspaceWithExistingContent() : void {
    $this->createContentType([
        'type' => 'test',
        'label' => 'Test',
    ]);
    // Login and create a workspace.
    $permissions = [
        'administer workspaces',
        'create test content',
        'delete any test content',
    ];
    $this->drupalLogin($this->drupalCreateUser($permissions));
    $this->createAndActivateWorkspaceThroughUi('May 4', 'may_4');
    // Create a node in the workspace.
    $this->createNodeThroughUi('A mayfly flies / In May or June', 'test');
    // Delete the workspace.
    $this->drupalGet('/admin/config/workflow/workspaces/manage/may_4/delete');
    $this->assertSession()
        ->statusCodeEquals(200);
    $page = $this->getSession()
        ->getPage();
    $page->findButton('Delete')
        ->click();
    $page->hasContent('The workspace May 4 has been deleted.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.