/**
  * Tests that the listener does use the response if the Contao framework is booted.
  *
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testWithContaoFramework()
 {
     $this->framework->expects($this->any())->method('isInitialized')->willReturn(true);
     $listener = new AddToSearchIndexListener($this->framework);
     $event = $this->mockPostResponseEvent();
     $event->expects($this->once())->method('getResponse')->willReturn(new Response());
     $listener->onKernelTerminate($event);
 }
예제 #2
0
 /**
  * Returns a ContaoFramework instance.
  *
  * @param RequestStack                   $requestStack  The request stack
  * @param RouterInterface                $router        The router object
  * @param CsrfTokenManagerInterface|null $tokenManager  An optional token manager
  * @param ConfigAdapter|null             $configAdatper An optional config adapter
  *
  * @return ContaoFramework The object instance
  */
 public function mockContaoFramework(RequestStack $requestStack = null, RouterInterface $router = null, CsrfTokenManagerInterface $tokenManager = null, ConfigAdapter $configAdatper = null)
 {
     // Ensure to use the fixtures class
     Config::preload();
     $container = $this->mockContainerWithContaoScopes();
     if (null === $requestStack) {
         $requestStack = $container->get('request_stack');
     }
     if (null === $router) {
         $router = $this->mockRouter('/index.html');
     }
     if (null === $tokenManager) {
         $tokenManager = new CsrfTokenManager($this->getMock('Symfony\\Component\\Security\\Csrf\\TokenGenerator\\TokenGeneratorInterface'), $this->getMock('Symfony\\Component\\Security\\Csrf\\TokenStorage\\TokenStorageInterface'));
     }
     if (null === $configAdatper) {
         $configAdatper = $this->mockConfig();
     }
     $framework = new ContaoFramework($requestStack, $router, $this->mockSession(), $this->getRootDir() . '/app', $tokenManager, 'contao_csrf_token', $configAdatper, error_reporting());
     $framework->setContainer($container);
     return $framework;
 }