Skip to content

Commit

Permalink
MDL-40700 tests: skip if there is not instance
Browse files Browse the repository at this point in the history
Various reasons can lead to the cache stores not being available
(missing extension, configuration...). Under those situations
the test must be skipped because for sure it will break if
we continue.
  • Loading branch information
stronk7 committed Jul 23, 2013
1 parent 52affa8 commit e681d0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cache/stores/memcache/tests/memcache_test.php
Expand Up @@ -67,6 +67,10 @@ public function test_valid_keys() {
$definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_memcache', 'phpunit_test');
$instance = cachestore_memcache::initialise_test_instance($definition);

if (!$instance) { // Something prevented memcache store to be inited (extension, TEST_CACHESTORE_MEMCACHE_TESTSERVERS...).
$this->markTestSkipped();
}

$keys = array(
// Alphanumeric.
'abc', 'ABC', '123', 'aB1', '1aB',
Expand All @@ -86,4 +90,4 @@ public function test_valid_keys() {
$this->assertEquals($key, $value);
}
}
}
}
6 changes: 5 additions & 1 deletion cache/stores/memcached/tests/memcached_test.php
Expand Up @@ -67,6 +67,10 @@ public function test_valid_keys() {
$definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_memcached', 'phpunit_test');
$instance = cachestore_memcached::initialise_test_instance($definition);

if (!$instance) { // Something prevented memcached store to be inited (extension, TEST_CACHESTORE_MEMCACHED_TESTSERVERS...).
$this->markTestSkipped();
}

$keys = array(
// Alphanumeric.
'abc', 'ABC', '123', 'aB1', '1aB',
Expand All @@ -86,4 +90,4 @@ public function test_valid_keys() {
$this->assertEquals($key, $value);
}
}
}
}

0 comments on commit e681d0e

Please sign in to comment.