Ejemplo n.º 1
0
 /**
  * @covers \ZF\HttpCache\HttpCacheListener::onRoute
  * @dataProvider configDataProvider
  *
  * @param array  $config
  * @param string $method
  * @param array  $routeMatch
  * @param array  $exCacheConfig
  */
 public function testOnRoute(array $config, $method, array $routeMatch, array $exCacheConfig)
 {
     $request = new HttpRequest();
     $request->setMethod($method);
     $event = new MvcEvent();
     $event->setRequest($request);
     $event->setRouteMatch(new RouteMatch($routeMatch));
     $this->instance->setConfig($config)->onRoute($event);
     $cacheConfig = $this->instance->getCacheConfig();
     $this->assertSame(!empty($cacheConfig), $this->instance->hasCacheConfig());
     $this->assertSame($exCacheConfig, $cacheConfig);
 }
 /**
  * Factory for producing an HttpCacheListener.
  *
  * Duck-types on the $container type to allow usage with
  * zend-servicemanager versions 2.5+ and 3.0+.
  *
  * @param  ContainerInterface $container
  * @return HttpCacheListener
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = [];
     if ($container->has('config')) {
         $config = $container->get('config');
         if (isset($config['zf-http-cache'])) {
             $config = $config['zf-http-cache'];
         }
     }
     $httpCacheListener = new HttpCacheListener($this->getETagGenerator($config, $container));
     $httpCacheListener->setConfig($config);
     return $httpCacheListener;
 }