function CacheCollectorTest::testUpdateCacheLockFail

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCacheLockFail()
  2. 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCacheLockFail()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testUpdateCacheLockFail()

Tests updating the cache when the lock acquire fails.

File

core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php, line 200

Class

CacheCollectorTest
@coversDefaultClass \Drupal\Core\Cache\CacheCollector[[api-linebreak]] @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function testUpdateCacheLockFail() : void {
  $key = $this->randomMachineName();
  $value = $this->randomMachineName();
  $this->collector
    ->setCacheMissData($key, $value);
  $this->collector
    ->get($key);
  // The lock acquire returns false, so the method should abort.
  $this->lock
    ->expects($this->once())
    ->method('acquire')
    ->with($this->cid . ':Drupal\\Core\\Cache\\CacheCollector')
    ->willReturn(FALSE);
  $this->cacheBackend
    ->expects($this->never())
    ->method('set');
  // 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.