function WorkspaceTest::testWorkspaceToolbar

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

Tests that the toolbar correctly shows the active workspace.

File

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

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testWorkspaceToolbar() : void {
  $this->drupalLogin($this->editor1);
  $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('<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/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.