diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php index 04414dc..1786b76 100644 --- a/core/modules/node/src/Tests/Views/FrontPageTest.php +++ b/core/modules/node/src/Tests/Views/FrontPageTest.php @@ -8,6 +8,7 @@ namespace Drupal\node\Tests\Views; use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\node\Entity\Node; @@ -194,6 +195,7 @@ public function testAdminFrontPage() { public function testCacheTagsWithCachePluginNone() { $this->enablePageCaching(); $this->assertFrontPageViewCacheTags(FALSE); + $this->assertCacheMaxAge(0); } /** @@ -210,6 +212,7 @@ public function testCacheTagsWithCachePluginTag() { $view->save(); $this->assertFrontPageViewCacheTags(TRUE); + $this->assertCacheMaxAge(CacheBackendInterface::CACHE_PERMANENT); } /** diff --git a/core/modules/views/src/Plugin/views/cache/None.php b/core/modules/views/src/Plugin/views/cache/None.php index 4ef83b5..4b7e3ba 100644 --- a/core/modules/views/src/Plugin/views/cache/None.php +++ b/core/modules/views/src/Plugin/views/cache/None.php @@ -27,6 +27,14 @@ public function summaryTitle() { return $this->t('None'); } + /** + * Gets the max age for the current view. + * + * @return int + */ + public function getCacheMaxAge() { + return 0; + } /** * Overrides \Drupal\views\Plugin\views\cache\CachePluginBase::cacheGet(). diff --git a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php index 4ec2c41..0e3ce00 100644 --- a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php +++ b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php @@ -8,8 +8,10 @@ namespace Drupal\views\Tests; use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\entity_test\Entity\EntityTest; +use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait; use Drupal\views\Views; use Drupal\views\Entity\View; @@ -21,6 +23,7 @@ class RenderCacheIntegrationTest extends ViewUnitTestBase { use AssertViewsCacheTagsTrait; + use AssertPageCacheContextsAndTagsTrait; /** * {@inheritdoc} @@ -47,6 +50,7 @@ protected function setUp() { */ public function testFieldBasedViewCacheTagsWithCachePluginNone() { $this->assertCacheTagsForFieldBasedView(FALSE); + $this->assertCacheMaxAge(0); } /** @@ -60,6 +64,7 @@ public function testFieldBasedViewCacheTagsWithCachePluginTag() { $view->save(); $this->assertCacheTagsForFieldBasedView(TRUE); + $this->assertCacheMaxAge(CacheBackendInterface::CACHE_PERMANENT); } /** @@ -137,6 +142,7 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) { */ public function testEntityBasedViewCacheTagsWithCachePluginNone() { $this->assertCacheTagsForEntityBasedView(FALSE); + $this->assertCacheMaxAge(0); } /** @@ -150,6 +156,7 @@ public function testEntityBasedViewCacheTagsWithCachePluginTag() { $view->save(); $this->assertCacheTagsForEntityBasedView(TRUE); + $this->assertCacheMaxAge(CacheBackendInterface::CACHE_PERMANENT); } /**