mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-84124 cache: Purge Redis cache between tests
This commit is contained in:
parent
c58bc49a07
commit
00f0ec3ccf
17
cache/stores/redis/tests/compressor_test.php
vendored
17
cache/stores/redis/tests/compressor_test.php
vendored
@ -37,10 +37,10 @@ require_once(__DIR__.'/../lib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
final class compressor_test extends \advanced_testcase {
|
||||
/** @var null|\cachestore_redis */
|
||||
protected ?cachestore_redis $store = null;
|
||||
|
||||
/**
|
||||
* Test set up
|
||||
*/
|
||||
#[\Override]
|
||||
public function setUp(): void {
|
||||
if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) {
|
||||
$this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.');
|
||||
@ -49,6 +49,16 @@ final class compressor_test extends \advanced_testcase {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function tearDown(): void {
|
||||
parent::tearDown();
|
||||
|
||||
if ($this->store !== null) {
|
||||
$this->store->purge();
|
||||
$this->store = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a cachestore.
|
||||
*
|
||||
@ -64,6 +74,7 @@ final class compressor_test extends \advanced_testcase {
|
||||
$config['serializer'] = $serializer;
|
||||
$store = new cachestore_redis('Test', $config);
|
||||
$store->initialise($definition);
|
||||
$this->store = $store;
|
||||
|
||||
return $store;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user