Skip to content
Snippets Groups Projects
Commit 7a615251 authored by Francesco Placella's avatar Francesco Placella
Browse files

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

Issue #2934354 by amateescu, Fabianx, alexpott: Expose cacheability metadata in WorkspaceCacheContext
parent cf458f2e
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment