function WorkspaceTest::testPublishWorkspace

Same name in other branches
  1. 10 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testPublishWorkspace()

Verifies that a workspace can be published.

File

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

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testPublishWorkspace() : void {
    $this->createContentType([
        'type' => 'test',
        'label' => 'Test',
    ]);
    $permissions = [
        'administer workspaces',
        'create test content',
    ];
    $this->drupalLogin($this->drupalCreateUser($permissions));
    $this->drupalGet('/admin/config/workflow/workspaces/add');
    $this->submitForm([
        'id' => 'test_workspace',
        'label' => 'Test workspace',
    ], 'Save');
    // Activate the test workspace.
    $this->drupalGet('/admin/config/workflow/workspaces/manage/test_workspace/activate');
    $this->submitForm([], 'Confirm');
    $this->drupalGet('/admin/config/workflow/workspaces/manage/test_workspace/publish');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('There are no changes that can be published from Test workspace to Live.');
    // Create a node in the workspace.
    $this->createNodeThroughUi('Test node', 'test');
    $this->drupalGet('/admin/config/workflow/workspaces/manage/test_workspace/publish');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('There is 1 item that can be published from Test workspace to Live');
    $this->getSession()
        ->getPage()
        ->pressButton('Publish 1 item to Live');
    $this->assertSession()
        ->pageTextContains('Successful publication.');
}

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