diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-12 00:26:05 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-12 00:26:05 -0700 |
commit | ec36276c4ef52066a5e653d82450bd94c22824b5 (patch) | |
tree | 99bcd25d95a48131f8a11276dafa7dd150dc84b2 /modules/simpletest | |
parent | 9824d7ac2502bb63501f53df24b8f17d18b2a242 (diff) | |
download | brdo-ec36276c4ef52066a5e653d82450bd94c22824b5.tar.gz brdo-ec36276c4ef52066a5e653d82450bd94c22824b5.tar.bz2 |
Issue #1015946 by pillarsdotnet, catch, bfroehle, Jej, jose.guevara, Damien Tournoud: Fixed Eliminate ->cache and {session}.cache in favor of ['cache_expiration()'][].
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/cache.test | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/simpletest/tests/cache.test b/modules/simpletest/tests/cache.test index d292fa661..47f2df318 100644 --- a/modules/simpletest/tests/cache.test +++ b/modules/simpletest/tests/cache.test @@ -339,6 +339,40 @@ class CacheClearCase extends CacheTestCase { $this->assertFalse($this->checkCacheExists($id, $this->default_value, $bin), t('All cache entries removed from @bin.', array('@bin' => $bin))); } } + + /** + * Test minimum cache lifetime. + */ + function testMinimumCacheLifetime() { + // Set a minimum/maximum cache lifetime. + $this->setupLifetime(300); + // Login as a newly-created user. + $account = $this->drupalCreateUser(array()); + $this->drupalLogin($account); + + // Set two cache objects in different bins. + $data = $this->randomName(100); + cache_set($data, $data, 'cache', CACHE_TEMPORARY); + $cached = cache_get($data); + $this->assertTrue(isset($cached->data) && $cached->data === $data, 'Cached item retrieved.'); + cache_set($data, $data, 'cache_page', CACHE_TEMPORARY); + + // Expire temporary items in the 'page' bin. + cache_clear_all(NULL, 'cache_page'); + + // Since the database cache uses REQUEST_TIME, set the $_SESSION variable + // manually to force it to the current time. + $_SESSION['cache_expiration']['cache_page'] = time(); + + // Items in the default cache bin should not be expired. + $cached = cache_get($data); + $this->assertTrue(isset($cached->data) && $cached->data == $data, 'Cached item retrieved'); + + // Despite the minimum cache lifetime, the item in the 'page' bin should + // be invalidated for the current user. + $cached = cache_get($data, 'cache_page'); + $this->assertFalse($cached, 'Cached item was invalidated'); + } } /** |