function WorkspaceTest::doTestWorkspaceToolbar

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

Tests that the toolbar correctly shows the active workspace.

File

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

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function doTestWorkspaceToolbar() : void {
  $this->drupalLogin($this->editor1);
  $this->drupalGet('/admin/config/workflow/workspaces/add');
  $this->submitForm([
    'id' => 'test_workspace_1',
    'label' => 'Test workspace',
  ], 'Save');
  // Activate the test workspace.
  $this->drupalGet('/admin/config/workflow/workspaces/manage/test_workspace_1/activate');
  $this->submitForm([], 'Confirm');
  $this->drupalGet('<front>');
  $page = $this->getSession()
    ->getPage();
  // Toolbar should show the correct label.
  $this->assertTrue($page->hasLink('Test workspace'));
  // Change the workspace label.
  $this->drupalGet('/admin/config/workflow/workspaces/manage/test_workspace_1/edit');
  $this->submitForm([
    'label' => 'New name',
  ], 'Save');
  $this->drupalGet('<front>');
  $page = $this->getSession()
    ->getPage();
  // Toolbar should show the new label.
  $this->assertTrue($page->hasLink('New name'));
}

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