function CacheCollectorTest::testUpdateCacheDelete
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCacheDelete()
- 10 core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCacheDelete()
- 11.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCacheDelete()
Tests updating the cache after a delete.
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheCollectorTest.php, line 298
Class
- CacheCollectorTest
- @coversDefaultClass \Drupal\Core\Cache\CacheCollector @group Cache
Namespace
Drupal\Tests\Core\CacheCode
public function testUpdateCacheDelete() {
$key = $this->randomMachineName();
$value = $this->randomMachineName();
$cache = (object) [
'data' => [
$key => $value,
],
'created' => (int) $_SERVER['REQUEST_TIME'],
];
// Set up mock expectation, on the second call the with the second argument
// set to TRUE because we triggered a cache invalidation.
$this->cacheBackend
->expects($this->exactly(2))
->method('get')
->withConsecutive([
$this->cid,
], [
$this->cid,
TRUE,
])
->willReturn($cache);
$this->collector
->delete($key);
// Set up mock objects for the expected calls, first a lock acquire, 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')
->willReturn(TRUE);
$this->cacheBackend
->expects($this->once())
->method('set')
->with($this->cid, [], Cache::PERMANENT, []);
$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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.