You are here

protected function WorkspaceTestUtilities::switchToWorkspace in Workspace 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspace\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\workspace\WorkspaceInterface $workspace: The workspace to set active.

3 calls to WorkspaceTestUtilities::switchToWorkspace()
WorkspaceBypassTest::testBypassOwnWorkspace in tests/src/Functional/WorkspaceBypassTest.php
Verifies that a user can edit anything in a workspace they own.
WorkspaceConcurrentEditingTest::testSwitchingWorkspaces in tests/src/Functional/WorkspaceConcurrentEditingTest.php
Test switching workspace via the switcher block and admin page.
WorkspaceSwitcherTest::testSwitchingWorkspaces in tests/src/Functional/WorkspaceSwitcherTest.php
Test switching workspace via the switcher block and admin page.

File

tests/src/Functional/WorkspaceTestUtilities.php, line 96

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspace\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.');
}