/** * Testing cachestore_file::get with prescan enabled and with * deleting the cache between the prescan and the call to get. * * The deleting of cache simulates some other process purging * the cache. */ public function test_cache_get_with_prescan_and_purge() { global $CFG; $definition = cache_definition::load_adhoc(cache_store::MODE_REQUEST, 'cachestore_file', 'phpunit_test'); $name = 'File test'; $path = make_cache_directory('cachestore_file_test'); $cache = new cachestore_file($name, array('path' => $path, 'prescan' => true)); $cache->initialise($definition); $cache->set('testing', 'value'); $path = make_cache_directory('cachestore_file_test'); $cache = new cachestore_file($name, array('path' => $path, 'prescan' => true)); $cache->initialise($definition); // Let's pretend that some other process purged caches. remove_dir($CFG->cachedir . '/cachestore_file_test', true); make_cache_directory('cachestore_file_test'); $cache->get('testing'); }
/** * Generates an instance of the cache store that can be used for testing. * * Returns an instance of the cache store, or false if one cannot be created. * * @param cache_definition $definition * @return cachestore_file */ public static function initialise_test_instance(cache_definition $definition) { $name = 'File test'; $path = make_cache_directory('cachestore_file_test'); $cache = new cachestore_file($name, array('path' => $path)); $cache->initialise($definition); return $cache; }