$config = $factory->create_config_instance();
$this->assertEquals('cache_config_phpunittest', get_class($config));
}
+
+ /**
+ * Test that multiple loaders work ok.
+ */
+ public function test_multiple_loaders() {
+ $instance = cache_config_phpunittest::instance(true);
+ $instance->phpunit_add_file_store('phpunittest1');
+ $instance->phpunit_add_file_store('phpunittest2');
+ $instance->phpunit_add_definition('phpunit/multi_loader', array(
+ 'mode' => cache_store::MODE_APPLICATION,
+ 'component' => 'phpunit',
+ 'area' => 'multi_loader'
+ ));
+ $instance->phpunit_add_definition_mapping('phpunit/multi_loader', 'phpunittest1', 3);
+ $instance->phpunit_add_definition_mapping('phpunit/multi_loader', 'phpunittest2', 2);
+
+ $cache = cache::make('phpunit', 'multi_loader');
+ $this->assertInstanceOf('cache_application', $cache);
+ $this->assertFalse($cache->get('test'));
+ $this->assertTrue($cache->set('test', 'test'));
+ $this->assertEquals('test', $cache->get('test'));
+ }
}
\ No newline at end of file
public function phpunit_remove_stores() {
$this->configstores = array();
}
+
+ /**
+ * Forcefully adds a file store.
+ *
+ * @param string $name
+ */
+ public function phpunit_add_file_store($name) {
+ $this->configstores[$name] = array(
+ 'name' => $name,
+ 'plugin' => 'file',
+ 'configuration' => array(
+ 'path' => ''
+ ),
+ 'features' => 6,
+ 'modes' => 3,
+ 'mappingsonly' => false,
+ 'class' => 'cachestore_file',
+ 'default' => false,
+ 'lock' => 'cachelock_file_default'
+ );
+ }
+
+ /**
+ * Forcefully injects a definition => store mapping.
+ *
+ * This function does no validation, you should only be calling if it you know
+ * exactly what to expect.
+ *
+ * @param string $definition
+ * @param string $store
+ * @param int $sort
+ */
+ public function phpunit_add_definition_mapping($definition, $store, $sort) {
+ $this->configdefinitionmappings[] = array(
+ 'store' => $store,
+ 'definition' => $definition,
+ 'sort' => (int)$sort
+ );
+ }
}
/**