/** * @test */ function it_removes_a_cache_tags_on_inctercept_suffix() { $this->pool->method('hasItem')->with('key')->willReturn(true); $this->pool->expects($this->once())->method('clearTags')->with(['tag1', 'tag2']); $annotation = new CacheEvict(['pools' => 'pool', 'tags' => 'tag1, tag2']); $interception = new ProxyInterceptionSuffix(new \stdClass(), 'method', ['key1' => 'value1'], 'returnValue'); $result = $this->interceptor->interceptSuffix($annotation, $interception); $this->assertInstanceOf(EvictResult::class, $result); }
/** * @test */ function it_doesnt_load_result_if_cache_is_expired() { $item = (new CacheItem('key'))->set('value')->expiresAt(new \DateTime('now - 1 hour')); $this->pool->method('hasItem')->with('key')->willReturn(false); $this->pool->method('getItem')->with('key')->willReturn($item); $annotation = new Cacheable(['pools' => 'pool']); $interception = new ProxyInterceptionPrefix(new \stdClass(), 'method', ['key1' => 'value1']); $result = $this->interceptor->interceptPrefix($annotation, $interception); $this->assertInstanceOf(EmptyResult::class, $result); }