Example #1
0
 /**
  * Tests setting and invalidating
  *
  * @dataProvider providerTestInvalidCharacters
  */
 public function testCacheCollector($cid, $key, $value)
 {
     $collector = new CacheCollectorHelper($cid, $this->container->get('cache.default'), $this->container->get('lock'));
     $this->assertNull($collector->get($key));
     $collector->set($key, $value);
     $this->assertEquals($value, $collector->get($key));
     $collector->destruct();
     // @todo Shouldn't this be empty after destruction?
     $this->assertEquals($value, $collector->get($key));
 }
Example #2
0
 /**
  * Tests a clear of the cache collector using tags.
  */
 public function testUpdateCacheClearTags()
 {
     $key = $this->randomMachineName();
     $value = $this->randomMachineName();
     $tags = array($this->randomMachineName());
     $this->collector = new CacheCollectorHelper($this->cid, $this->cacheBackend, $this->lock, $tags);
     // Set the data and request it.
     $this->collector->setCacheMissData($key, $value);
     $this->assertEquals($value, $this->collector->get($key));
     $this->assertEquals($value, $this->collector->get($key));
     // Should have been added to the storage and only be requested once.
     $this->assertEquals(1, $this->collector->getCacheMisses());
     // Clear the collected cache using the tags, should call it again.
     $this->cacheBackend->expects($this->never())->method('delete');
     $this->cacheTagsInvalidator->expects($this->once())->method('invalidateTags')->with($tags);
     $this->collector->clear();
     $this->assertEquals($value, $this->collector->get($key));
     $this->assertEquals(2, $this->collector->getCacheMisses());
 }