You are here

public function WorkspaceSwitcherTest::testSwitchingWorkspaces in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php \Drupal\Tests\workspaces\Functional\WorkspaceSwitcherTest::testSwitchingWorkspaces()

Tests switching workspace via the switcher block and admin page.

File

core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php, line 50

Class

WorkspaceSwitcherTest
Tests workspace switching functionality.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testSwitchingWorkspaces() {
  $vultures = $this
    ->createWorkspaceThroughUi('Vultures', 'vultures');
  $this
    ->switchToWorkspace($vultures);
  $gravity = $this
    ->createWorkspaceThroughUi('Gravity', 'gravity');
  $this
    ->drupalGet('/admin/config/workflow/workspaces/manage/' . $gravity
    ->id() . '/activate');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->findButton('Confirm')
    ->click();

  // Check that WorkspaceCacheContext provides the cache context used to
  // support its functionality.
  $this
    ->assertCacheContext('session');
  $page
    ->findLink($gravity
    ->label());
}