protected function setUp() { $this->poolManager = new PoolManager(); $this->pool = $this->getMockBuilder(TaggablePoolInterface::class)->getMock(); $this->keyGenerator = $this->getMockBuilder(KeyGeneratorInterface::class)->getMock(); $this->keyGenerator->method('generateKey')->willReturn('key'); $this->poolManager->addPool('pool', $this->pool); $this->interceptor = new CacheEvictInterceptor($this->poolManager, $this->keyGenerator); }
/** * @param InterceptionInterface $interception * @param CacheAnnotationInterface $annotation * * @return string * @throws \Phpro\AnnotatedCache\Exception\UnsupportedKeyParameterException */ public function generateKey(InterceptionInterface $interception, CacheAnnotationInterface $annotation) : string { $format = property_exists($annotation, 'key') ? $annotation->key : ''; $parameters = array_merge($interception->getParams(), ['interception' => $interception]); if ($format && ($result = $this->language->evaluate($format, $parameters))) { return sha1(serialize($result)); } return $this->keyGenerator->generateKey($interception, $annotation); }
/** * @param CacheAnnotationInterface $annotation * @param InterceptionInterface $interception * * @return string */ private function calculateKey(CacheAnnotationInterface $annotation, InterceptionInterface $interception) : string { return $this->keyGenerator->generateKey($interception, $annotation); }
/** * @param $instance * @param $method * @param $key * @param $parameters * * @return string */ private function calculateKey($instance, $method, $key, $parameters) { $interception = new TestInterception($instance, $method, $parameters); $annotation = new TestAnnotation(['key' => $key]); return $this->keyGenerator->generateKey($interception, $annotation); }