예제 #1
0
 /**
  * @return void
  */
 public function testGetStaticViewFileContext()
 {
     $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false);
     $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']);
     $this->themeProvider->expects($this->any())->method('getThemeByFullPath')->willReturnArgument(0);
     $this->httpMock->expects($this->any())->method('isSecure')->willReturn(false);
     $fallbackContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File\\FallbackContex')->disableOriginalConstructor()->getMock();
     $this->fallbackFactoryMock->expects($this->once())->method('create')->with(['baseUrl' => '', 'areaType' => 'area', 'themePath' => '', 'localeCode' => 'locale', 'isSecure' => ''])->willReturn($fallbackContextMock);
     $this->assertEquals($fallbackContextMock, $this->repository->getStaticViewFileContext());
 }
예제 #2
0
 /**
  * Get a fallback context value object
  *
  * Create only one instance per combination of parameters
  *
  * @param string $urlType
  * @param bool|null $isSecure
  * @param string $area
  * @param string $themePath
  * @param string $locale
  * @return \Magento\Framework\View\Asset\File\FallbackContext
  */
 private function getFallbackContext($urlType, $isSecure, $area, $themePath, $locale)
 {
     $secureKey = null === $isSecure ? 'null' : (int) $isSecure;
     $baseDirType = DirectoryList::STATIC_VIEW;
     $id = implode('|', [$baseDirType, $urlType, $secureKey, $area, $themePath, $locale]);
     if (!isset($this->fallbackContext[$id])) {
         $url = $this->baseUrl->getBaseUrl(['_type' => $urlType, '_secure' => $isSecure]);
         $this->fallbackContext[$id] = $this->fallbackContextFactory->create(['baseUrl' => $url, 'areaType' => $area, 'themePath' => $themePath, 'localeCode' => $locale, 'isSecure' => $isSecure]);
     }
     return $this->fallbackContext[$id];
 }