Skip to content

Commit

Permalink
Merge branch 'MDL-45603-27' of https://github.com/merrill-oakland/moodle
Browse files Browse the repository at this point in the history
 into MOODLE_27_STABLE
  • Loading branch information
Sam Hemelryk committed May 20, 2014
2 parents cc41096 + d8e7fa9 commit dadeff8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cache/classes/helper.php
Expand Up @@ -719,7 +719,8 @@ public static function get_stores_suitable_for_definition(cache_definition $defi
return $stores;
} else {
$stores = self::get_cache_stores($definition);
if (count($stores) === 0) {
// If mappingsonly is set, having 0 stores is ok.
if ((count($stores) === 0) && (!$definition->is_for_mappings_only())) {
// No suitable stores we found for the definition. We need to come up with a sensible default.
// If this has happened we can be sure that the user has mapped custom stores to either the
// mode of the definition. The first alternative to try is the system default for the mode.
Expand Down
27 changes: 27 additions & 0 deletions cache/tests/cache_test.php
Expand Up @@ -470,6 +470,33 @@ public function test_definition_overridden_loader() {
$this->assertEquals('Test has no value really.', $cache->get('Test'));
}

/**
* Test the mappingsonly setting.
*/
public function test_definition_mappings_only() {
$instance = cache_config_phpunittest::instance(true);
$instance->phpunit_add_definition('phpunit/mappingsonly', array(
'mode' => cache_store::MODE_APPLICATION,
'component' => 'phpunit',
'area' => 'mappingsonly',
'mappingsonly' => true
));
$instance->phpunit_add_definition('phpunit/nonmappingsonly', array(
'mode' => cache_store::MODE_APPLICATION,
'component' => 'phpunit',
'area' => 'nonmappingsonly',
'mappingsonly' => false
));

$cacheonly = cache::make('phpunit', 'mappingsonly');
$this->assertInstanceOf('cache_application', $cacheonly);
$this->assertEquals('cachestore_dummy', $cacheonly->phpunit_get_store_class());

$cachenon = cache::make('phpunit', 'nonmappingsonly');
$this->assertInstanceOf('cache_application', $cachenon);
$this->assertEquals('cachestore_file', $cachenon->phpunit_get_store_class());
}

/**
* Test a very basic definition.
*/
Expand Down

0 comments on commit dadeff8

Please sign in to comment.