function WorkspaceTest::testDeleteWorkspaceWithExistingContent

Same name in other branches
  1. 10 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 251

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testDeleteWorkspaceWithExistingContent() {
    $this->createContentType([
        'type' => 'test',
        'label' => 'Test',
    ]);
    $this->setupWorkspaceSwitcherBlock();
    // Login and create a workspace.
    $this->drupalLogin($this->rootUser);
    $may_4 = $this->createWorkspaceThroughUi('May 4', 'may_4');
    $this->switchToWorkspace($may_4);
    // Create a node in the workspace.
    $node = $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.