You are here

public function WorkspaceTest::testWorkspaceToolbar in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceToolbar()
  2. 9 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 96

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testWorkspaceToolbar() {
  $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'));
}