/**
  * {@inheritdoc}
  */
 public function switchAction(Request $request)
 {
     if ($this->themeContainer instanceof ThemeContainerInterface) {
         $this->themes = $this->themeContainer->getThemeList();
     }
     return parent::switchAction($request);
 }
Example #2
0
 /**
  * @dataProvider dataProvider
  */
 public function testThemeAction($config, $assertion, $hasAlreadyACookie = true)
 {
     $activeTheme = new ActiveTheme($config['active_theme'], $config['themes']);
     $device = null;
     if ($config['autodetect_theme']) {
         $device = $this->getDeviceDetectionMock('autodetect');
     }
     $response = new \Symfony\Component\HttpFoundation\Response();
     $request = new \Symfony\Component\HttpFoundation\Request();
     if ($hasAlreadyACookie) {
         $request = $this->getMockRequest('cookie');
     }
     $controller = false;
     if ($config['load_controllers']) {
         $controller = new ThemeController($activeTheme, $config['themes'], $config['cookie']);
     }
     $listener = new ThemeRequestListener($activeTheme, $config['cookie'], $device);
     $listener->onKernelRequest($this->getEventMock($request, $response, 'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent'));
     $this->assertEquals($activeTheme->getName(), $assertion['themeAfterKernelRequest']);
     if ($controller) {
         $response = $controller->switchAction($this->getMockRequest($assertion['themeAfterController']));
         $this->assertCookieValue($response, $assertion['themeAfterController']);
     }
     // onResponse will not set the cookie if the controller modified it
     $listener->onKernelResponse($this->getEventMock($request, $response, 'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent'));
     $this->assertCookieValue($response, $assertion['themeAfterKernelResponse']);
 }