Merge branch '46208-26' of git://github.com/samhemelryk/moodle into MOODLE_26_STABLE

This commit is contained in:
Eloy Lafuente (stronk7)
2014-07-08 02:15:51 +02:00
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
throw new coding_exception('This mongodb instance has already been initialised.');
}
$this->database = $this->connection->selectDB($this->databasename);
$this->definitionhash = $definition->generate_definition_hash();
$this->definitionhash = 'm'.$definition->generate_definition_hash();
$this->collection = $this->database->selectCollection($this->definitionhash);
$options = array('name' => 'idx_key');
+22
View File
@@ -59,4 +59,26 @@ class cachestore_mongodb_test extends cachestore_tests {
protected function get_class_name() {
return 'cachestore_mongodb';
}
/**
* A small additional test to make sure definitions that hash a hash starting with a number work OK
*/
public function test_collection_name() {
// This generates a definition that has a hash starting with a number. MDL-46208.
$definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_mongodb', 'abc');
$instance = cachestore_mongodb::initialise_test_instance($definition);
if (!$instance) {
$this->markTestSkipped();
}
$this->assertTrue($instance->set(1, 'alpha'));
$this->assertTrue($instance->set(2, 'beta'));
$this->assertEquals('alpha', $instance->get(1));
$this->assertEquals('beta', $instance->get(2));
$this->assertEquals(array(
1 => 'alpha',
2 => 'beta'
), $instance->get_many(array(1, 2)));
}
}