function WorkspaceSwitcherTest::testSwitchingWorkspaces
Tests switching workspace via the switcher block and admin page.
File
-
core/
modules/ workspaces/ tests/ src/ Functional/ WorkspaceSwitcherTest.php, line 66
Class
- WorkspaceSwitcherTest
- Tests workspace switching functionality.
Namespace
Drupal\Tests\workspaces\FunctionalCode
public function testSwitchingWorkspaces() : void {
/** @var \Drupal\Core\Cache\CacheBackendInterface $entity_cache */
$entity_cache = \Drupal::service('cache.entity');
$node_type = $this->drupalCreateContentType();
$node = $this->drupalCreateNode([
'type' => $node_type->id(),
]);
$this->assertFalse($entity_cache->get("values:node:{$node->id()}"));
// Access the node page to prime its persistent cache.
$this->drupalGet($node->toUrl());
$this->assertNotFalse($entity_cache->get("values:node:{$node->id()}"));
$vultures = Workspace::load('vultures');
$gravity = Workspace::load('gravity');
$this->switchToWorkspace($vultures);
// Check that switching into a workspace doesn't invalidate the persistent
// cache.
$this->assertNotFalse($entity_cache->get("values:node:{$node->id()}"));
// 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.