*/ private VersionedCache $cache; protected function setUp(): void { parent::setUp(); $this->delegate = new FakeCache(); $this->cache = new VersionedCache($this->delegate); } public function test_set_value_sets_value_in_delegate_with_changed_key(): void { $this->cache->set('foo', 'foo'); self::assertTrue($this->cache->has('foo')); self::assertFalse($this->delegate->has('foo')); self::assertSame('foo', $this->cache->get('foo')); } public function test_delete_entry_deletes_entry(): void { $this->cache->set('foo', 'foo'); $this->cache->delete('foo'); self::assertFalse($this->cache->has('foo')); } public function test_clear_entries_clears_everything(): void { $this->cache->set('foo', 'foo'); $this->cache->clear(); self::assertFalse($this->cache->has('foo')); } public function test_setting_values_sets_values_in_delegate_with_changed_key(): void { $values = [ 'foo' => 'foo', 'bar' => 'bar', ]; $this->cache->setMultiple($values); self::assertTrue($this->cache->has('foo')); self::assertTrue($this->cache->has('bar')); self::assertFalse($this->delegate->has('foo')); self::assertFalse($this->delegate->has('bar')); self::assertSame($values, iterator_to_array($this->cache->getMultiple(['foo', 'bar']))); } public function test_delete_entries_deletes_correct_entries(): void { $this->cache->setMultiple([ 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz', ]); $this->cache->deleteMultiple(['foo', 'baz']); self::assertFalse($this->cache->has('foo')); self::assertTrue($this->cache->has('bar')); self::assertFalse($this->cache->has('baz')); } }