diff --git a/modules/simpletest/tests/cache.test b/modules/simpletest/tests/cache.test index 6f8f3b8..084f131 100644 --- a/modules/simpletest/tests/cache.test +++ b/modules/simpletest/tests/cache.test @@ -441,19 +441,19 @@ class CacheInstallTestCase extends CacheTestCase { * the installer makes changes that would result in it becoming stale. * * We cannot test this process directly, so instead we test it by switching - * between the normal database cache (Drupal\Core\Cache\DatabaseBackend) and - * the installer cache (Drupal\Core\Cache\InstallBackend) while setting and + * between the normal database cache (DrupalDatabaseCache) and + * the installer cache (DrupalFakeCache) while setting and * clearing various items in the cache. */ function testCacheInstall() { - $database_cache = new DatabaseBackend('test'); - $install_cache = new InstallBackend('test'); + $database_cache = new DrupalDatabaseCache('test'); + $install_cache = new DrupalFakeCache('test'); // Store an item in the database cache, and confirm that the installer's // cache backend recognizes that the cache is not empty. $database_cache->set('cache_one', 'One'); $this->assertFalse($install_cache->isEmpty()); - $database_cache->delete('cache_one'); + $database_cache->clear('cache_one'); $this->assertTrue($install_cache->isEmpty()); // Store an item in the database cache, then use the installer's cache @@ -461,74 +461,9 @@ class CacheInstallTestCase extends CacheTestCase { // database cache. $database_cache->set('cache_one', 'One'); $this->assertEqual($database_cache->get('cache_one')->data, 'One'); - $install_cache->delete('cache_one'); + $install_cache->clear('cache_one'); $this->assertFalse($database_cache->get('cache_one')); - // Store multiple items in the database cache, then use the installer's - // cache backend to delete them. Afterwards, confirm that they are no - // longer in the database cache. - $database_cache->set('cache_one', 'One'); - $database_cache->set('cache_two', 'Two'); - $this->assertEqual($database_cache->get('cache_one')->data, 'One'); - $this->assertEqual($database_cache->get('cache_two')->data, 'Two'); - $install_cache->deleteMultiple(array('cache_one', 'cache_two')); - $this->assertFalse($database_cache->get('cache_one')); - $this->assertFalse($database_cache->get('cache_two')); - - // Store multiple items in the database cache, then use the installer's - // cache backend to delete them via a wildcard prefix. Afterwards, confirm - // that they are no longer in the database cache. - $database_cache->set('cache_one', 'One'); - $database_cache->set('cache_two', 'Two'); - $this->assertEqual($database_cache->get('cache_one')->data, 'One'); - $this->assertEqual($database_cache->get('cache_two')->data, 'Two'); - $install_cache->deletePrefix('cache_'); - $this->assertFalse($database_cache->get('cache_one')); - $this->assertFalse($database_cache->get('cache_two')); - - // Store multiple items in the database cache, then use the installer's - // cache backend to flush the cache. Afterwards, confirm that they are no - // longer in the database cache. - $database_cache->set('cache_one', 'One'); - $database_cache->set('cache_two', 'Two'); - $this->assertEqual($database_cache->get('cache_one')->data, 'One'); - $this->assertEqual($database_cache->get('cache_two')->data, 'Two'); - $install_cache->flush(); - $this->assertFalse($database_cache->get('cache_one')); - $this->assertFalse($database_cache->get('cache_two')); - - // Store multiple items in the database cache with a temporary expiration, - // then use the installer's cache backend to expire outdated items. - // Afterwards, confirm that they are no longer in the database cache. - $database_cache->set('cache_one', 'One', CACHE_TEMPORARY); - $database_cache->set('cache_two', 'Two', CACHE_TEMPORARY); - $this->assertEqual($database_cache->get('cache_one')->data, 'One'); - $this->assertEqual($database_cache->get('cache_two')->data, 'Two'); - $install_cache->expire(); - $this->assertFalse($database_cache->get('cache_one')); - $this->assertFalse($database_cache->get('cache_two')); - - // Store multiple items in the database cache with a temporary expiration, - // then use the installer's cache backend to perform garbage collection. - // Afterwards, confirm that they are no longer in the database cache. - $database_cache->set('cache_one', 'One', CACHE_TEMPORARY); - $database_cache->set('cache_two', 'Two', CACHE_TEMPORARY); - $this->assertEqual($database_cache->get('cache_one')->data, 'One'); - $this->assertEqual($database_cache->get('cache_two')->data, 'Two'); - // After we've checked that the items are in the cache, we need to enable - // garbage collection before running the garbage collector. - config('system.performance')->set('cache_lifetime', 1)->save(); - variable_set('cache_flush_cache_test', 1); - $install_cache->garbageCollection(); - $this->assertFalse($database_cache->get('cache_one')); - $this->assertFalse($database_cache->get('cache_two')); - - // Invalidate a tag using the installer cache, then check that the - // invalidation was recorded correctly in the database. - $install_cache->invalidateTags(array('tag')); - $invalidations = db_query("SELECT invalidations FROM {cache_tags} WHERE tag = 'tag'")->fetchField(); - $this->assertEqual($invalidations, 1); - // For each cache clearing event that we tried above, try it again after // dropping the {cache_test} table. This simulates the early stages of the // installer (when the database cache tables won't be available yet) and @@ -538,13 +473,7 @@ class CacheInstallTestCase extends CacheTestCase { db_drop_table('cache_test'); try { $install_cache->isEmpty(); - $install_cache->delete('cache_one'); - $install_cache->deleteMultiple(array('cache_one', 'cache_two')); - $install_cache->deletePrefix('cache_'); - $install_cache->flush(); - $install_cache->expire(); - $install_cache->garbageCollection(); - $install_cache->invalidateTags(array('tag')); + $install_cache->clear('cache_one'); $this->pass("The installer's cache backend can be used even when the cache database tables are unavailable."); } catch (Exception $e) {