public function test_different_caches_have_different_prefixes() { $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test'); $instance = new cachestore_apcu('Test', cachestore_apcu::unit_test_configuration()); $instance->initialise($definition); $definition2 = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test2'); $instance2 = new cachestore_apcu('Test', cachestore_apcu::unit_test_configuration()); $instance2->initialise($definition2); $instance->set('test1', 1); $this->assertFalse($instance2->get('test1')); $instance2->purge(); $this->assertSame(1, $instance->get('test1')); }
/** * Generates an instance of the cache store that can be used for testing. * * @param cache_definition $definition * @return cachestore_apcu|false */ public static function initialise_unit_test_instance(cache_definition $definition) { if (!self::are_requirements_met()) { return false; } $store = new cachestore_apcu('Test APCu', array('prefix' => 'phpunit')); if (!$store->is_ready()) { return false; } $store->initialise($definition); return $store; }
/** * Generates an instance of the cache store that can be used for testing. * * @param cache_definition $definition * @return cachestore_apcu|false */ public static function initialise_unit_test_instance(cache_definition $definition) { if (!self::are_requirements_met()) { return false; } if (!defined('TEST_CACHESTORE_APCU')) { return false; } $store = new cachestore_apcu('Test APCu', array()); if (!$store->is_ready()) { return false; } $store->initialise($definition); return $store; }
/** * 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 cache_store */ public static function initialise_test_instance(cache_definition $definition) { $testperformance = get_config('cachestore_apcu', 'testperformance'); if (empty($testperformance)) { return false; } if (!self::are_requirements_met()) { return false; } $name = 'APCu test'; $cache = new cachestore_apcu($name); // No need to check if is_ready() as this has already being done by requirement check. $cache->initialise($definition); return $cache; }