protected function tearDown() { parent::tearDown(); if ($this->store instanceof cachestore_redis) { $this->store->purge(); } }
public function test_purge() { $otherstore = new cachestore_redis('test2', array('server' => CACHESTORE_REDIS_TEST_SERVER, 'prefix' => 'phpunit2')); $this->assertTrue($otherstore->set('nopurge', 'value')); // Calling purge on empty cache should be OK. $this->assertTrue($this->store->purge()); $this->assertTrue($this->store->set('foo', 'bar')); $this->assertTrue($this->store->set('bat', 'baz')); $this->assertTrue($this->store->set('this', 'that')); $this->assertTrue($this->store->purge()); $this->assertFalse($this->store->get('foo', 'bar')); $this->assertFalse($this->store->get('bat', 'baz')); $this->assertFalse($this->store->get('this', 'that')); // Our other store should not be affected! $this->assertEquals('value', $otherstore->get('nopurge')); // Cleanup... $this->assertTrue($otherstore->purge()); }