/**
  * @test
  */
 function it_intercepts_proxy_suffix()
 {
     $interception = new ProxyInterceptionSuffix(new \stdClass(), 'someMethod', ['key1' => 'param1'], 'returnValue');
     $result = new HitResult($interception, 'key', ['pool'], 'someNewValue');
     $this->interceptor->method('canInterceptAnnotation')->with($this->annotation)->willReturn(true);
     $this->interceptor->method('interceptSuffix')->with($this->annotation, $interception)->willReturn($result);
     $this->resultCollector->expects($this->once())->method('collect')->with($result);
     $result = $this->cacheHandler->interceptProxySuffix(new AnnotationCollection([$this->annotation]), $interception);
     $this->assertEquals('someNewValue', $result);
 }
示例#2
0
 /**
  * @param PoolManager                $poolManager
  * @param KeyGeneratorInterface|null $keyGenerator
  * @param ResultCollectorInterface   $resultCollector
  *
  * @return CacheHandler
  */
 public static function createCacheHandler(PoolManager $poolManager, KeyGeneratorInterface $keyGenerator = null, ResultCollectorInterface $resultCollector = null) : CacheHandler
 {
     $keyGenerator = $keyGenerator ?? self::createKeyGenerator();
     $resultCollector = $resultCollector ?? new NullResultCollector();
     $cacheHandler = new CacheHandler($resultCollector);
     $cacheHandler->addInterceptor(new Interceptor\CacheableInterceptor($poolManager, $keyGenerator));
     $cacheHandler->addInterceptor(new Interceptor\CacheUpdateInterceptor($poolManager, $keyGenerator));
     $cacheHandler->addInterceptor(new Interceptor\CacheEvictInterceptor($poolManager, $keyGenerator));
     return $cacheHandler;
 }
 /**
  * @test
  */
 function it_does_not_interact_with_methods_that_dont_have_caching_annotations()
 {
     $instance = new ProxyInstance();
     $this->cacheHandler->expects($this->never())->method('interceptProxyPrefix');
     $this->cacheHandler->expects($this->never())->method('interceptProxySuffix');
     /** @var ProxyInstance $proxy */
     $proxy = $this->proxyGenerator->generate($instance);
     $result = $proxy->passThrough('value');
     $this->assertEquals('normal', $result);
 }