esi_response_object = new EsiResponse('', ['ETag' => 'W/"b3ef78b1064a27974cbf18270c1f126d519f7b467ba2e35ccb6f0819"'], 'now', 200); } public function testMemcachedCacheInstantiates() { $cache = new MemcachedCache(); $this->assertInstanceOf(MemcachedCache::class, $cache); } public function testMemcachedCacheBuildsCacheKey() { $cache = new MemcachedCache(); $key = $cache->buildCacheKey('/test', 'foo=bar'); $this->assertEquals('eseye:b0f071c288f528954cddef0e1aa24df41de874aa', $key); } public function testMemcachedCacheSetsKey() { // Mock a memcache instance $instance = $this->getMockBuilder(stdClass::class)->addMethods(['set', 'get'])->getMock(); $instance->expects($this->once())->method('set')->willReturn(true); $instance->expects($this->once())->method('get')->willReturn(serialize($this->esi_response_object)); // Set the cache $cache = new MemcachedCache($instance); $cache->set('/foo', 'foo=bar', $this->esi_response_object); $this->assertEquals($this->esi_response_object, $cache->get('/foo', 'foo=bar')); } public function testMemcachedCacheForgetsKey() { // Mock a memcache instance $instance = $this->getMockBuilder(stdClass::class)->addMethods(['delete', 'get'])->getMock(); $instance->expects($this->once())->method('delete')->willReturn(true); $instance->expects($this->once())->method('get')->willReturn(false); // Set the cache $cache = new MemcachedCache($instance); $cache->forget('/foo', 'foo=bar'); $this->assertFalse($cache->get('/foo', 'foo=bar')); } }