Commit 7a615251 authored by plach's avatar plach

Issue #2934354 by amateescu, Fabianx, alexpott: Expose cacheability metadata...

Issue #2934354 by amateescu, Fabianx, alexpott: Expose cacheability metadata in WorkspaceCacheContext
parent cf458f2e
......@@ -47,7 +47,11 @@ public function getContext() {
* {@inheritdoc}
*/
public function getCacheableMetadata($type = NULL) {
return new CacheableMetadata();
// The active workspace will always be stored in the user's session.
$cacheability = new CacheableMetadata();
$cacheability->addCacheContexts(['session']);
return $cacheability;
}
}
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\workspace\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
/**
* Tests workspace switching functionality.
......@@ -11,6 +12,7 @@
*/
class WorkspaceSwitcherTest extends BrowserTestBase {
use AssertPageCacheContextsAndTagsTrait;
use WorkspaceTestUtilities;
/**
......@@ -52,6 +54,10 @@ public function testSwitchingWorkspaces() {
$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());
}
......@@ -70,6 +76,10 @@ public function testQueryParameterNegotiator() {
// The workspace switching via query parameter should persist.
$this->drupalGet('<front>');
$web_assert->elementContains('css', '.block-workspace-switcher', 'Stage');
// Check that WorkspaceCacheContext provides the cache context used to
// support its functionality.
$this->assertCacheContext('session');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment