Ejemplo n.º 1
0
 /**
  * @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);
 }
Ejemplo n.º 2
0
 /**
  * @param AnnotationCollection  $annotations
  * @param InterceptionInterface $interception
  * @param Closure               $callback
  *
  * @return mixed
  */
 private function runInterceptors(AnnotationCollection $annotations, InterceptionInterface $interception, Closure $callback)
 {
     foreach ($annotations as $annotation) {
         foreach ($this->interceptors as $interceptor) {
             if (!$interceptor->canInterceptAnnotation($annotation)) {
                 continue;
             }
             $result = $callback($interceptor, $annotation, $interception);
             $this->resultCollector->collect($result);
             if ($result instanceof ContentAwareResultInterface && $result->hasContent()) {
                 return $result->getContent();
             }
         }
     }
     return null;
 }
 /**
  * @param Request        $request
  * @param Response       $response
  * @param Exception|null $exception
  */
 public function collect(Request $request, Response $response, Exception $exception = null)
 {
     $results = $this->collector->getResults();
     $this->data = array('hits' => $results->countHits(), 'miss' => $results->countMisses(), 'results' => $results->toArray(), 'cacheable_results' => $results->filterByType(HittableResultInterface::class)->toArray(), 'cache_evict_results' => $results->filterByType(EvictResult::class)->toArray(), 'cache_update_results' => $results->filterByType(UpdateResult::class)->toArray());
 }