public function testWithInvalidCookie()
 {
     $activeTheme = $this->getActiveThemeStub();
     $activeTheme->expects($this->never())->method('setName');
     $listener = new ThemeRequestListener($activeTheme, array('name' => $this->testCookieName));
     $listener->onKernelRequest($this->getResponseEventMock('noActualTheme'));
 }
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']);
 }