function WorkspaceTestUtilities::switchToWorkspace

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

Sets a given workspace as "active" for subsequent requests.

This assumes that the switcher block has already been setup by calling setupWorkspaceSwitcherBlock().

Parameters

\Drupal\workspaces\WorkspaceInterface $workspace: The workspace to set active.

1 call to WorkspaceTestUtilities::switchToWorkspace()
WorkspaceConcurrentEditingTest::testConcurrentEditing in core/modules/workspaces/tests/src/Functional/WorkspaceConcurrentEditingTest.php
Test editing a node in multiple workspaces.

File

core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php, line 99

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function switchToWorkspace(WorkspaceInterface $workspace) {
  /** @var \Drupal\Tests\WebAssert $session */
  $session = $this->assertSession();
  $session->buttonExists('Activate');
  $this->drupalPostForm(NULL, [
    'workspace_id' => $workspace->id(),
  ], 'Activate');
  $session->pageTextContains($workspace->label() . ' is now the active workspace.');
}

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