diff --git a/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php b/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php index f88ba11..307a853 100644 --- a/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php +++ b/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php @@ -98,4 +98,33 @@ public function testCacheBinExpirationSetMultiple() { $this->assertIdentical($cached->expire, (string) (REQUEST_TIME + 2800), 'Maximum cache expire time is not exceeded.'); } + public function testCacheBinNoExpiration() { + // Empty configuration would force DatabaseBackend to select permanent + // lifetime for cache objects. + $configuration = []; + $backend = new DatabaseBackend($this->container->get('database'), $this->container->get('cache_tags.invalidator.checksum'), 'render', $configuration); + + $backend->setMultiple([ + 'test_cache1' => [ + 'data' => 'foo', + ], + 'test_cache2' => [ + 'data' => 'foo', + 'expire' => REQUEST_TIME + 2799, + ], + ]); + + // Test set as well. + $backend->set('test_cache3', 'foo', REQUEST_TIME + 2801); + + $cached = $backend->get('test_cache1'); + $this->assertIdentical($cached->expire, (string) (-1), 'Maximum cache expire time is correct.'); + + $cached = $backend->get('test_cache2'); + $this->assertIdentical($cached->expire, (string) (REQUEST_TIME + 2799), 'Maximum cache expire time is correct.'); + + $cached = $backend->get('test_cache3'); + $this->assertIdentical($cached->expire, (string) (REQUEST_TIME + 2801), 'Maximum cache expire time is correct.'); + } + }