diff -u b/core/modules/page_cache/src/Tests/PageCacheTest.php b/core/modules/page_cache/src/Tests/PageCacheTest.php --- b/core/modules/page_cache/src/Tests/PageCacheTest.php +++ b/core/modules/page_cache/src/Tests/PageCacheTest.php @@ -3,6 +3,7 @@ namespace Drupal\page_cache\Tests; use Drupal\Component\Datetime\DateTimePlus; +use Drupal\Core\Site\Settings; use Drupal\Core\Url; use Drupal\entity_test\Entity\EntityTest; use Drupal\simpletest\WebTestBase; @@ -374,6 +375,14 @@ $this->drupalGet($content_url); $this->assertResponse($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); + + // Ensure the expires date on the cache entry uses negative_cache_ttl. + $cache_entry = \Drupal::service('cache.render')->get($this->getUrl() . ':html'); + $difference = $cache_entry->expire - (int) $cache_entry->created; + // Account for any rounding errors by rounding the difference ot the + // nearest 10. As long as negative_cache_ttl is a multiple of 10 then this + // will work. + $this->assertEqual(round($difference, -1), Settings::get('negative_cache_ttl', 3600), 'The cache entry expiry time uses the negative_cache_ttl setting.'); } // Disable 403 and 404 caching.