diff -u b/core/tests/Drupal/Tests/Core/Cache/InconsistentBackendTest.php b/core/tests/Drupal/Tests/Core/Cache/InconsistentBackendTest.php --- b/core/tests/Drupal/Tests/Core/Cache/InconsistentBackendTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/InconsistentBackendTest.php @@ -45,21 +45,24 @@ } public function testFallThroughToConsistentCache() { - // TODO: Refactor to use mocks for at least inconsistent cache backend so - // that we can assert that ::set gets called n times. $state = $this->getMock("Drupal\Core\KeyValueStore\StateInterface"); $state->expects($this->once()) ->method("get") ->will($this->returnValue(time() + 99999)); + $inconsistent_cache = $this->getMock("Drupal\Core\Cache\MemoryBackend", + array("set"), array("foo")); + $inconsistent_cache->expects($this->exactly(2)) + ->method("set"); + $inconsistent_backend = new ChainedConsistentAndInconsistentBackend( $this->consistent_cache, - $this->inconsistent_cache, + $inconsistent_cache, $this->bin, $state ); - $this->inconsistent_cache->set("foo", "bar"); + $inconsistent_cache->set("foo", "bar"); $this->consistent_cache->set("foo", "baz"); $this->assertEquals("baz", $inconsistent_backend->get("foo")->data); }