Пример #1
0
 /**
  * Creates the required cachestore for the tests to run against Redis.
  *
  * @return cachestore_redis
  */
 protected function create_cachestore_redis()
 {
     /** @var cache_definition $definition */
     $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_redis', 'phpunit_test');
     $store = new cachestore_redis('Test', cachestore_redis::unit_test_configuration());
     $store->initialise($definition);
     $this->store = $store;
     if (!$store) {
         $this->markTestSkipped();
     }
     return $store;
 }
 public function test_initialise()
 {
     $this->assertTrue($this->store->initialise(new cache_definition()));
     $this->assertTrue($this->store->is_initialised());
 }
Пример #3
0
 /**
  * Creates an instance of the store for testing.
  *
  * @param cache_definition $definition
  * @return mixed An instance of the store, or false if an instance cannot be created.
  */
 public static function initialise_test_instance(cache_definition $definition)
 {
     if (!self::are_requirements_met()) {
         return false;
     }
     $config = get_config('cachestore_redis');
     if (empty($config->test_server)) {
         return false;
     }
     $cache = new cachestore_redis('Redis test', ['server' => $config->test_server]);
     $cache->initialise($definition);
     return $cache;
 }