function WorkspaceSwitcherTest::testSwitchingWorkspaces

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php \Drupal\Tests\workspaces\Functional\WorkspaceSwitcherTest::testSwitchingWorkspaces()
  2. 8.9.x core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php \Drupal\Tests\workspaces\Functional\WorkspaceSwitcherTest::testSwitchingWorkspaces()
  3. 11.x 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 59

Class

WorkspaceSwitcherTest
Tests workspace switching functionality.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testSwitchingWorkspaces() : void {
    $this->createAndActivateWorkspaceThroughUi('Vultures', 'vultures');
    $gravity = $this->createWorkspaceThroughUi('Gravity', 'gravity');
    // Confirm the block shows on the front page.
    $this->drupalGet('<front>');
    $page = $this->getSession()
        ->getPage();
    $this->assertTrue($page->hasContent('Workspace switcher'));
    $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());
}

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