protected function setUp()
 {
     $this->annotation = $this->getMockBuilder(CacheAnnotationInterface::class)->getMock();
     $this->interceptor = $this->getMockBuilder(InterceptorInterface::class)->getMock();
     $this->resultCollector = $this->getMockBuilder(ResultCollectorInterface::class)->getMock();
     $this->cacheHandler = new CacheHandler($this->resultCollector);
     $this->cacheHandler->addInterceptor($this->interceptor);
 }
Example #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;
 }