MDL-47608 cachestore_mongo: fixed unit test error
authorSam Hemelryk <sam@moodle.com>
Wed, 8 Oct 2014 20:12:59 +0000 (09:12 +1300)
committerSam Hemelryk <sam@moodle.com>
Sun, 19 Oct 2014 22:03:57 +0000 (11:03 +1300)
If you configured your site to run mongo unit tests and had
the mongo extension and backend installed but did not have the
mongo service running you would get a fatal error when running
the unit tests.
That problem has been fixed by checking the mongo test instance
is ready before returning it.

cache/stores/mongodb/lib.php

index 4405da4..e4d51ec 100644 (file)
@@ -556,6 +556,9 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
         }
 
         $store = new cachestore_mongodb('Test mongodb', $configuration);
         }
 
         $store = new cachestore_mongodb('Test mongodb', $configuration);
+        if (!$store->is_ready()) {
+            return false;
+        }
         $store->initialise($definition);
 
         return $store;
         $store->initialise($definition);
 
         return $store;
@@ -581,6 +584,9 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
         $configuration['usesafe'] = 1;
 
         $store = new cachestore_mongodb('Test mongodb', $configuration);
         $configuration['usesafe'] = 1;
 
         $store = new cachestore_mongodb('Test mongodb', $configuration);
+        if (!$store->is_ready()) {
+            return false;
+        }
         $store->initialise($definition);
 
         return $store;
         $store->initialise($definition);
 
         return $store;