public function CacheCollectorTest::testUpdateCache in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCache()
Tests updating the cache after a set.
File
- core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheCollectorTest.php, line 172 - Contains \Drupal\Tests\Core\Cache\CacheCollectorTest.
Class
- CacheCollectorTest
- @coversDefaultClass \Drupal\Core\Cache\CacheCollector @group Cache
Namespace
Drupal\Tests\Core\CacheCode
public function testUpdateCache() {
$key = $this
->randomMachineName();
$value = $this
->randomMachineName();
$this->collector
->setCacheMissData($key, $value);
$this->collector
->get($key);
// Set up mock objects for the expected calls, first a lock acquire, then
// cache get to look for conflicting cache entries, then a cache set and
// finally the lock is released again.
$this->lock
->expects($this
->once())
->method('acquire')
->with($this->cid . ':Drupal\\Core\\Cache\\CacheCollector')
->will($this
->returnValue(TRUE));
$this->cacheBackend
->expects($this
->once())
->method('get')
->with($this->cid, FALSE);
$this->cacheBackend
->expects($this
->once())
->method('set')
->with($this->cid, array(
$key => $value,
), Cache::PERMANENT, array());
$this->lock
->expects($this
->once())
->method('release')
->with($this->cid . ':Drupal\\Core\\Cache\\CacheCollector');
// Destruct the object to trigger the update data process.
$this->collector
->destruct();
}