protected function WorkspaceTestUtilities::switchToWorkspace in Workspace 8
Same name and namespace in other branches
- 8.2 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\multiversion\Entity\WorkspaceInterface $workspace: The workspace to set active.
9 calls to WorkspaceTestUtilities::switchToWorkspace()
- ReplicationSettingsTest::testPullReplicationSettings in tests/
src/ Functional/ ReplicationSettingsTest.php - Verify pull replication settings using the published filter as an example.
- ReplicationSettingsTest::testPushReplicationSettings in tests/
src/ Functional/ ReplicationSettingsTest.php - Verify push replication settings using the published filter as an example.
- ReplicatorAliasTest::testReplicationAlias in tests/
src/ Functional/ ReplicatorAliasTest.php - Verifies that a user can edit anything in a workspace with a specific perm.
- ReplicatorTest::testReplication in tests/
src/ Functional/ ReplicatorTest.php - Test replication.
- ReplicatorTest::testSelectiveContentReplication in tests/
src/ Functional/ ReplicatorTest.php - Test selective content replication.
File
- tests/
src/ Functional/ WorkspaceTestUtilities.php, line 123
Class
- WorkspaceTestUtilities
- Utility methods for use in BrowserTestBase tests.
Namespace
Drupal\Tests\workspace\FunctionalCode
protected function switchToWorkspace(WorkspaceInterface $workspace) {
// Switch the test runner's context to the specified workspace.
\Drupal::service('workspace.manager')
->setActiveWorkspace($workspace);
// Switch the system under test to the specified workspace.
$this
->drupalGet('<front>');
$this
->getSession()
->getPage()
->findButton($workspace
->label())
->click();
// If we don't do both of those, test runner utility methods will not be
// run in the same workspace as the system under test, and you'll be left
// wondering why your test runner cannot find content you just created.
}