/** * Test flush. * * @dataProvider cacheProvider */ public function testFlush(CacheInterface $cache) { $this->assertTrue($cache->save('foo', 'bar')); $this->assertEquals('bar', $cache->fetch('foo')); $this->assertTrue($cache->flush()); $this->assertFalse($cache->contains('foo')); $this->assertNull($cache->fetch('foo')); }
/** * Do empty namespace tests. */ protected function doTestEmptyNamespace(CacheInterface $decoratedCache) { // ensure we are clean $decoratedCache->flush(); if ($decoratedCache instanceof NamespaceCache) { $decoratedCache->getCache()->flush(); } $cache = new NamespaceCache($decoratedCache); $this->assertFalse($cache->contains('yin')); $this->assertNull($cache->fetch('yin')); $this->assertTrue($cache->save('yin', 'yang')); $this->assertTrue($cache->contains('yin')); $this->assertEquals('yang', $cache->fetch('yin')); // check decorated cache as that should be the same $this->assertTrue($decoratedCache->contains('yin')); $cache->flush(); if ($stats = $decoratedCache->getStats()) { $this->assertFalse($cache->contains('foo')); $this->assertEquals(0, $stats[CacheInterface::STATS_SIZE]); } }