function WorkspaceTestUtilities::switchToWorkspace
Same name in other branches
- 8.9.x core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::switchToWorkspace()
- 10 core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::switchToWorkspace()
- 11.x 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.
9 calls to WorkspaceTestUtilities::switchToWorkspace()
- PathWorkspacesTest::testPathAliases in core/
modules/ workspaces/ tests/ src/ Functional/ PathWorkspacesTest.php - Tests path aliases with workspaces.
- PathWorkspacesTest::testPathAliasesUserSwitch in core/
modules/ workspaces/ tests/ src/ Functional/ PathWorkspacesTest.php - Tests path aliases with workspaces and user switching.
- PathWorkspacesTest::testPathAliasesWithTranslation in core/
modules/ workspaces/ tests/ src/ Functional/ PathWorkspacesTest.php - Tests path aliases with workspaces for translatable nodes.
- WorkspaceBypassTest::testBypassOwnWorkspace in core/
modules/ workspaces/ tests/ src/ Functional/ WorkspaceBypassTest.php - Verifies that a user can edit anything in a workspace they own.
- WorkspaceConcurrentEditingTest::testConcurrentEditing in core/
modules/ workspaces/ tests/ src/ Functional/ WorkspaceConcurrentEditingTest.php - Tests editing a node in multiple workspaces.
File
-
core/
modules/ workspaces/ tests/ src/ Functional/ WorkspaceTestUtilities.php, line 103
Class
- WorkspaceTestUtilities
- Utility methods for use in BrowserTestBase tests.
Namespace
Drupal\Tests\workspaces\FunctionalCode
protected function switchToWorkspace(WorkspaceInterface $workspace) {
$this->assertTrue($this->switcher_block_configured, 'This test was not written correctly: you must call setupWorkspaceSwitcherBlock() before switchToWorkspace()');
/** @var \Drupal\Tests\WebAssert $session */
$session = $this->assertSession();
$session->buttonExists('Activate');
$this->submitForm([
'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.