protected function setUp() { $this->assetsConfiguration = $this->getMockBuilder('Oro\\Bundle\\AsseticBundle\\AssetsConfiguration')->disableOriginalConstructor()->getMock(); $this->assetFactory = $this->getMockBuilder('Symfony\\Bundle\\AsseticBundle\\Factory\\AssetFactory')->disableOriginalConstructor()->getMock(); $this->themeRegistry = new ThemeRegistry($this->themes); $this->themeRegistry->setActiveTheme(self::ACTIVE_THEME); $this->parser = new FrontendAsseticTokenParser($this->assetsConfiguration, $this->assetFactory, $this->themeRegistry, self::TAG_NAME, self::PARSER_OUTPUT); }
/** * {@inheritdoc} */ protected function createDebugAsseticNode(\Twig_NodeInterface $body, array $filters, array $attributes, $lineno) { $currentTheme = $this->themeRegistry->getActiveTheme()->getName(); $this->themeRegistry->setActiveTheme(ThemeListener::FRONTEND_THEME); $node = parent::createDebugAsseticNode($body, $filters, $attributes, $lineno); $this->themeRegistry->setActiveTheme($currentTheme); return $node; }
public function testGetActiveTheme() { $this->assertNull($this->themeRegistry->getActiveTheme()); $this->themeRegistry->setActiveTheme('foo'); $activeTheme = $this->themeRegistry->getActiveTheme(); $this->assertInstanceOf('Oro\\Bundle\\ThemeBundle\\Model\\Theme', $activeTheme); $this->assertEquals('foo', $activeTheme->getName()); }
/** * @param boolean $installed * @param int $requestType * @param boolean $isFrontendRequest * @param string $expectedTheme * * @dataProvider onKernelRequestProvider */ public function testOnKernelRequest($installed, $requestType, $isFrontendRequest, $expectedTheme) { $this->themeRegistry->setActiveTheme('oro'); $request = new Request(); $event = new GetResponseEvent($this->kernel, $request, $requestType); $this->helper->expects($this->any())->method('isFrontendRequest')->with($request)->willReturn($isFrontendRequest); $listener = new ThemeListener($this->themeRegistry, $this->helper, $installed); $listener->onKernelRequest($event); $this->assertEquals($expectedTheme, $this->themeRegistry->getActiveTheme()->getName()); }
/** * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { if (!$this->installed) { return; } if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) { return; } if ($this->helper->isFrontendRequest($event->getRequest())) { $this->themeRegistry->setActiveTheme(self::FRONTEND_THEME); } }
/** * @param string $theme * @param bool $isDefaultTheme * @param bool $isDemoTheme * * @dataProvider isThemeDataProvider */ public function testIsTheme($theme, $isDefaultTheme, $isDemoTheme) { $this->themeRegistry->setActiveTheme($theme); $this->assertEquals($isDefaultTheme, $this->filter->isDefaultTheme()); $this->assertEquals($isDemoTheme, $this->filter->isDemoTheme()); }