コード例 #1
0
ファイル: ConfigTest.php プロジェクト: vasiljok/magento2
    public function testGetConfig()
    {
        $this->baseDir->expects($this->any())->method('getRelativePath')->will($this->returnCallback(function ($path) {
            return 'relative/' . $path;
        }));
        $this->baseDir->expects($this->any())->method('readFile')->will($this->returnCallback(function ($file) {
            return $file . ' content';
        }));
        $fileOne = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileOne->expects($this->once())->method('getFilename')->will($this->returnValue('file_one.js'));
        $fileOne->expects($this->once())->method('getModule')->will($this->returnValue('Module_One'));
        $fileTwo = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileTwo->expects($this->once())->method('getFilename')->will($this->returnValue('file_two.js'));
        $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
        $this->design->expects($this->once())->method('getDesignTheme')->will($this->returnValue($theme));
        $this->fileSource->expects($this->once())->method('getFiles')->with($theme, Config::CONFIG_FILE_NAME)->will($this->returnValue([$fileOne, $fileTwo]));
        $expected = <<<expected
(function(require){
require.config({"baseUrl":""});
(function() {
relative/file_one.js content
require.config(config);
})();
(function() {
relative/file_two.js content
require.config(config);
})();



})(require);
expected;
        $actual = $this->object->getConfig();
        $this->assertStringMatchesFormat($expected, $actual);
    }
コード例 #2
0
ファイル: Media.php プロジェクト: CompassPointMedia/magento2
 /**
  * @param ConfigInterface $configInterface
  * @param DesignInterface $designInterface
  * @param Context $context
  */
 public function __construct(ConfigInterface $configInterface, DesignInterface $designInterface, Context $context)
 {
     parent::__construct($context);
     $this->viewConfig = $configInterface;
     $this->currentTheme = $designInterface->getDesignTheme();
     $this->initConfig();
 }
コード例 #3
0
 /**
  * @test
  * @return void
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::beforeSave
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::_composeRegexp
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::_isRegexp
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::__construct
  */
 public function testBeforeSave()
 {
     $value = ['__empty' => '', 'test' => ['search' => '1qwe', 'value' => '#val#', 'regexp' => '[a-zA-Z0-9]*']];
     $this->designMock->expects($this->once())->method('setDesignTheme')->with('#val#', Area::AREA_FRONTEND);
     $this->model->setValue($value);
     $this->model->beforeSave();
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     switch ($scope) {
         case 'global':
             $iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
             $themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
             if ($themeConfigFile && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))) {
                 $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile($this->rootDirectory->getRelativePath($themeConfigFile));
             } else {
                 $designPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $this->currentTheme);
                 if (file_exists($designPath)) {
                     try {
                         $designDom = new \DOMDocument();
                         $designDom->load($designPath);
                         $iterator[$designPath] = $designDom->saveXML();
                     } catch (\Exception $e) {
                         throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Could not read config file'));
                     }
                 }
             }
             break;
         default:
             $iterator = $this->iteratorFactory->create([]);
             break;
     }
     return $iterator;
 }
コード例 #5
0
    public function testGetConfig()
    {
        $this->fileReader->expects($this->any())->method('readAll')->will($this->returnCallback(function ($file) {
            return $file . ' content';
        }));
        $fileOne = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileOne->expects($this->once())->method('getFilename')->will($this->returnValue('some/full/relative/path/file_one.js'));
        $fileOne->expects($this->once())->method('getName')->will($this->returnValue('file_one.js'));
        $fileOne->expects($this->once())->method('getModule')->will($this->returnValue('Module_One'));
        $fileTwo = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileTwo->expects($this->once())->method('getFilename')->will($this->returnValue('some/full/relative/path/file_two.js'));
        $fileTwo->expects($this->once())->method('getName')->will($this->returnValue('file_two.js'));
        $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
        $this->design->expects($this->once())->method('getDesignTheme')->will($this->returnValue($theme));
        $this->fileSource->expects($this->once())->method('getFiles')->with($theme, Config::CONFIG_FILE_NAME)->will($this->returnValue([$fileOne, $fileTwo]));
        $this->minificationMock->expects($this->atLeastOnce())->method('isEnabled')->with('js')->willReturn(true);
        $expected = <<<expected
(function(require){
(function() {
file_one.js content
require.config(config);
})();
(function() {
file_two.js content
require.config(config);
})();



})(require);
expected;
        $this->minifyAdapterMock->expects($this->once())->method('minify')->with($expected)->willReturnArgument(0);
        $actual = $this->object->getConfig();
        $this->assertEquals($actual, $expected);
    }
コード例 #6
0
 /**
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\View\Asset\GroupedCollection $assets
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param \Psr\Log\LoggerInterface $logger
  */
 public function __construct(\Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Asset\GroupedCollection $assets, \Magento\Framework\View\Asset\Repository $assetRepo, \Psr\Log\LoggerInterface $logger)
 {
     $this->currentTheme = $design->getDesignTheme();
     $this->pageAssets = $assets;
     $this->assetRepo = $assetRepo;
     $this->logger = $logger;
 }
コード例 #7
0
 /**
  * Initialize dependencies
  */
 protected function setUp()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(\Magento\Framework\View\DesignInterface::DEFAULT_AREA);
     $this->_design = $objectManager->get('Magento\\Framework\\View\\DesignInterface');
     $this->_design->setDesignTheme('Vendor/test_child');
     $this->_configFactory = $objectManager->create('Magento\\DesignEditor\\Model\\Editor\\Tools\\Controls\\Factory');
 }
コード例 #8
0
ファイル: Observer.php プロジェクト: aiesh/magento2
 /**
  * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\View\Asset\GroupedCollection $assets
  * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param Theme\Registration $registration
  * @param \Magento\Framework\Logger $logger
  */
 public function __construct(\Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Asset\GroupedCollection $assets, \Magento\Framework\App\Config\ReinitableConfigInterface $config, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Core\Model\Theme\Registration $registration, \Magento\Framework\Logger $logger)
 {
     $this->_cacheFrontendPool = $cacheFrontendPool;
     $this->_currentTheme = $design->getDesignTheme();
     $this->_pageAssets = $assets;
     $this->_assetRepo = $assetRepo;
     $this->_registration = $registration;
     $this->_logger = $logger;
 }
コード例 #9
0
 public function testGetByAreaWithOtherAreaAndNumericThemeId()
 {
     $this->designMock->expects($this->once())->method('getDesignTheme')->will($this->returnValue($this->themeMock));
     $this->designMock->expects($this->once())->method('getArea')->will($this->returnValue('design_area'));
     $this->designMock->expects($this->once())->method('getConfigurationDesignTheme')->will($this->returnValue(12));
     $this->themeMock->expects($this->once())->method('getArea')->will($this->returnValue('theme_area'));
     $this->themeCollectionFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->themeCollectionMock));
     $this->themeCollectionMock->expects($this->once())->method('getItemById')->with(12)->will($this->returnValue($this->themeMock));
     $this->appStateMock->expects($this->once())->method('getAreaCode')->will($this->returnValue('other_area'));
     $this->assertEquals($this->themeMock, $this->model->get());
 }
コード例 #10
0
ファイル: Observer.php プロジェクト: shabbirvividads/magento2
 /**
  * Initialize dependencies.
  *
  * @param \Magento\Framework\View\Design\Theme\ImageFactory $themeImageFactory
  * @param \Magento\Widget\Model\Resource\Layout\Update\Collection $updateCollection
  * @param \Magento\Theme\Model\Config\Customization $themeConfig
  * @param \Magento\Framework\Event\ManagerInterface $eventDispatcher
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\View\Asset\GroupedCollection $assets
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param Theme\Registration $registration
  * @param \Psr\Log\LoggerInterface $logger
  */
 public function __construct(\Magento\Framework\View\Design\Theme\ImageFactory $themeImageFactory, \Magento\Widget\Model\Resource\Layout\Update\Collection $updateCollection, \Magento\Theme\Model\Config\Customization $themeConfig, \Magento\Framework\Event\ManagerInterface $eventDispatcher, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Asset\GroupedCollection $assets, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Theme\Model\Theme\Registration $registration, \Psr\Log\LoggerInterface $logger)
 {
     $this->themeImageFactory = $themeImageFactory;
     $this->updateCollection = $updateCollection;
     $this->themeConfig = $themeConfig;
     $this->eventDispatcher = $eventDispatcher;
     $this->currentTheme = $design->getDesignTheme();
     $this->pageAssets = $assets;
     $this->assetRepo = $assetRepo;
     $this->registration = $registration;
     $this->logger = $logger;
 }
コード例 #11
0
 public function setUp()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->viewConfigMock = $this->getMock('\\Magento\\Framework\\View\\Config', ['getMediaAttributes', 'getViewConfig'], [], '', false);
     $this->viewConfigMock->expects($this->atLeastOnce())->method('getViewConfig')->willReturn($this->viewConfigMock);
     $this->themeCustomization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', [], [], '', false);
     $themeMock = $this->getMock('Magento\\Theme\\Model\\Theme', ['__wakeup', 'getCustomization'], [], '', false);
     $themeMock->expects($this->any())->method('getCustomization')->will($this->returnValue($this->themeCustomization));
     $this->currentThemeMock = $this->getMock('Magento\\Framework\\View\\DesignInterface');
     $this->currentThemeMock->expects($this->any())->method('getDesignTheme')->will($this->returnValue($themeMock));
     $this->mediaHelperObject = $objectManager->getObject('\\Magento\\ProductVideo\\Helper\\Media', ['configInterface' => $this->viewConfigMock, 'designInterface' => $this->currentThemeMock]);
 }
コード例 #12
0
 /**
  * Initialize dependencies
  */
 protected function setUp()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_design = $objectManager->get('Magento\\Framework\\View\\DesignInterface');
     $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(\Magento\Framework\View\DesignInterface::DEFAULT_AREA);
     $this->_design->setDesignTheme('Vendor/test');
     /** @var \Magento\Framework\View\Asset\Repository $assetRepo */
     $assetRepo = $objectManager->get('Magento\\Framework\\View\\Asset\\Repository');
     $quickStylesPath = $assetRepo->createAsset('Magento_DesignEditor::controls/quick_styles.xml')->getSourceFile();
     $this->assertFileExists($quickStylesPath);
     $this->_model = $objectManager->create('Magento\\DesignEditor\\Model\\Config\\Control\\QuickStyles', ['configFiles' => [file_get_contents($quickStylesPath)]]);
 }
コード例 #13
0
ファイル: ProductsListTest.php プロジェクト: nja78/magento2
 public function testGetCacheKeyInfo()
 {
     $store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['getId'])->getMock();
     $store->expects($this->once())->method('getId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->once())->method('getId')->willReturn('blank');
     $this->design->expects($this->once())->method('getDesignTheme')->willReturn($theme);
     $this->httpContext->expects($this->once())->method('getValue')->willReturn('context_group');
     $this->productsList->setData('conditions', 'some_serialized_conditions');
     $this->request->expects($this->once())->method('getParam')->with('np')->willReturn(1);
     $cacheKey = ['CATALOG_PRODUCTS_LIST_WIDGET', 1, 'blank', 'context_group', 1, 5, 'some_serialized_conditions'];
     $this->assertEquals($cacheKey, $this->productsList->getCacheKeyInfo());
 }
コード例 #14
0
 public function testGetCacheKeyInfo()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->atLeastOnce())->method('getId')->willReturn(55);
     $store->expects($this->atLeastOnce())->method('getRootCategoryId')->willReturn(60);
     $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->atLeastOnce())->method('getId')->willReturn(65);
     $this->design->expects($this->atLeastOnce())->method('getDesignTheme')->willReturn($theme);
     $this->httpContext->expects($this->atLeastOnce())->method('getValue')->with(\Magento\Customer\Model\Context::CONTEXT_GROUP)->willReturn(70);
     $this->block->setTemplate('block_template');
     $this->block->setNameInLayout('block_name');
     $expectedResult = ['CATALOG_NAVIGATION', 55, 65, 70, 'template' => 'block_template', 'name' => 'block_name', 60, 'category_path' => 60, 'short_cache_id' => 'c3de6d1160d1e7730b04d6cad409a2b4'];
     $this->assertEquals($expectedResult, $this->block->getCacheKeyInfo());
 }
コード例 #15
0
ファイル: Page.php プロジェクト: Atlis/docker-magento2
 /**
  * Renders CMS page
  *
  * @param Action $action
  * @param int $pageId
  * @param bool $renderLayout
  * @return bool
  */
 protected function _renderPage(Action $action, $pageId = null, $renderLayout = true)
 {
     if (!is_null($pageId) && $pageId !== $this->_page->getId()) {
         $delimiterPosition = strrpos($pageId, '|');
         if ($delimiterPosition) {
             $pageId = substr($pageId, 0, $delimiterPosition);
         }
         $this->_page->setStoreId($this->_storeManager->getStore()->getId());
         if (!$this->_page->load($pageId)) {
             return false;
         }
     }
     if (!$this->_page->getId()) {
         return false;
     }
     $inRange = $this->_localeDate->isScopeDateInInterval(null, $this->_page->getCustomThemeFrom(), $this->_page->getCustomThemeTo());
     if ($this->_page->getCustomTheme()) {
         if ($inRange) {
             $this->_design->setDesignTheme($this->_page->getCustomTheme());
         }
     }
     $this->_view->getLayout()->getUpdate()->addHandle('default')->addHandle('cms_page_view');
     $this->_view->addPageLayoutHandles(array('id' => $this->_page->getIdentifier()));
     $this->_view->addActionLayoutHandles();
     if ($this->_page->getRootTemplate()) {
         if ($this->_page->getCustomRootTemplate() && $this->_page->getCustomRootTemplate() != 'empty' && $inRange) {
             $handle = $this->_page->getCustomRootTemplate();
         } else {
             $handle = $this->_page->getRootTemplate();
         }
         $this->_pageLayout->applyHandle($handle);
     }
     $this->_eventManager->dispatch('cms_page_render', array('page' => $this->_page, 'controller_action' => $action));
     $this->_view->loadLayoutUpdates();
     if ($this->_page->getCustomLayoutUpdateXml() && $inRange) {
         $layoutUpdate = $this->_page->getCustomLayoutUpdateXml();
     } else {
         $layoutUpdate = $this->_page->getLayoutUpdateXml();
     }
     if (!empty($layoutUpdate)) {
         $this->_view->getLayout()->getUpdate()->addUpdate($layoutUpdate);
     }
     $this->_view->generateLayoutXml()->generateLayoutBlocks();
     $contentHeadingBlock = $this->_view->getLayout()->getBlock('page_content_heading');
     if ($contentHeadingBlock) {
         $contentHeading = $this->_escaper->escapeHtml($this->_page->getContentHeading());
         $contentHeadingBlock->setContentHeading($contentHeading);
     }
     if ($this->_page->getRootTemplate()) {
         $this->_pageLayout->applyTemplate($this->_page->getRootTemplate());
     }
     /* @TODO: Move catalog and checkout storage types to appropriate modules */
     $messageBlock = $this->_view->getLayout()->getMessagesBlock();
     $messageBlock->addStorageType($this->messageManager->getDefaultGroup());
     $messageBlock->addMessages($this->messageManager->getMessages(true));
     if ($renderLayout) {
         $this->_view->renderLayout();
     }
     return true;
 }
コード例 #16
0
ファイル: QuickStylesTest.php プロジェクト: aiesh/magento2
 /**
  * Initialize dependencies
  */
 protected function setUp()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Framework\App\Filesystem\DirectoryList $directoryList */
     $directoryList = $objectManager->get('Magento\\Framework\\App\\Filesystem\\DirectoryList');
     $path = str_replace($directoryList->getRoot(), '', str_replace('\\', '/', __DIR__) . '/../_files/design');
     $directoryList->addDirectory(\Magento\Framework\App\Filesystem::THEMES_DIR, array('path' => ltrim($path, '/')));
     $this->_design = $objectManager->get('Magento\\Framework\\View\\DesignInterface');
     $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(\Magento\Framework\View\DesignInterface::DEFAULT_AREA);
     $this->_design->setDesignTheme('vendor_test');
     /** @var \Magento\Framework\View\Asset\Repository $assetRepo */
     $assetRepo = $objectManager->get('Magento\\Framework\\View\\Asset\\Repository');
     $quickStylesPath = $assetRepo->createAsset('Magento_DesignEditor::controls/quick_styles.xml')->getSourceFile();
     $this->assertFileExists($quickStylesPath);
     $this->_model = $objectManager->create('Magento\\DesignEditor\\Model\\Config\\Control\\QuickStyles', array('configFiles' => array(file_get_contents($quickStylesPath))));
 }
コード例 #17
0
ファイル: EmulationTest.php プロジェクト: tingyeeh/magento2
 public function testStop()
 {
     // Test data
     $initArea = 'initial area';
     $initTheme = 'initial design theme';
     $initLocale = 'initial locale code';
     $initialStore = 1;
     $initTranslateInline = false;
     $this->inlineTranslationMock->expects($this->once())->method('isEnabled')->willReturn($initTranslateInline);
     $this->viewDesignMock->expects($this->once())->method('getArea')->willReturn($initArea);
     $this->viewDesignMock->expects($this->once())->method('getDesignTheme')->willReturn($initTheme);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getStoreId')->willReturn($initialStore);
     $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn($initLocale);
     $this->model->storeCurrentEnvironmentInfo();
     // Expectations
     $this->inlineTranslationMock->expects($this->once())->method('resume')->with($initTranslateInline);
     $this->viewDesignMock->expects($this->once())->method('setDesignTheme')->with($initTheme, $initArea);
     $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with($initialStore);
     $this->localeResolverMock->expects($this->once())->method('setLocale')->with($initLocale);
     $this->translateMock->expects($this->once())->method('setLocale')->with($initLocale);
     $this->translateMock->expects($this->once())->method('loadData')->with($initArea);
     // Test
     $this->model->stopEnvironmentEmulation();
 }
コード例 #18
0
ファイル: Repository.php プロジェクト: pavelnovitsky/magento2
 /**
  * Get current context for static view files
  *
  * @return \Magento\Framework\View\Asset\ContextInterface
  */
 public function getStaticViewFileContext()
 {
     $params = array();
     $this->updateDesignParams($params);
     $themePath = $this->design->getThemePath($params['themeModel']);
     return $this->getFallbackContext(UrlInterface::URL_TYPE_STATIC, null, $params['area'], $themePath, $params['locale']);
 }
コード例 #19
0
 /**
  * Get theme model based on the information from asset
  *
  * @param LocalInterface $asset
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 protected function getTheme(LocalInterface $asset)
 {
     $context = $asset->getContext();
     if ($context instanceof FallbackContext) {
         return $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode());
     }
     return $this->design->getDesignTheme();
 }
コード例 #20
0
 /**
  * Collect files
  *
  * @param string|null $searchPattern
  * @return array
  * @throws \Exception
  */
 public function collectFiles($searchPattern = null)
 {
     $result = [];
     if ($searchPattern === null) {
         $searchPattern = $this->searchPattern;
     }
     if ($searchPattern === null) {
         throw new \Exception('Search pattern cannot be empty.');
     }
     $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern);
     $fileReader = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
     foreach ($files as $file) {
         $filePath = $fileReader->getRelativePath($file->getFilename());
         $result[sprintf('%x', crc32($filePath))] = $fileReader->readFile($filePath);
     }
     return $result;
 }
コード例 #21
0
 /**
  * Retrieve design theme instance
  *
  * @return Design\ThemeInterface
  */
 public function getDesignTheme()
 {
     $theme = $this->design->getDesignTheme();
     $theme->setCode('Magento/plushe');
     $theme->setThemePath('Magento/plushe');
     $theme->setId(8);
     return $this->getPhysicalTheme($theme);
 }
コード例 #22
0
 /**
  * Retrieve instance of a theme currently used in an area
  *
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 public function get()
 {
     $area = $this->appState->getAreaCode();
     if ($this->design->getDesignTheme()->getArea() == $area || $this->design->getArea() == $area) {
         return $this->design->getDesignTheme();
     }
     /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection */
     $themeCollection = $this->themeFactory->create();
     $themeIdentifier = $this->design->getConfigurationDesignTheme($area);
     if (is_numeric($themeIdentifier)) {
         $result = $themeCollection->getItemById($themeIdentifier);
     } else {
         $themeFullPath = $area . \Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR . $themeIdentifier;
         $result = $themeCollection->getThemeByFullPath($themeFullPath);
     }
     return $result;
 }
コード例 #23
0
 private function mockDesign()
 {
     $params = array('area' => 'area', 'themeModel' => $this->theme, 'locale' => 'locale');
     $this->design->expects($this->atLeastOnce())->method('getDesignParams')->will($this->returnValue($params));
     $this->design->expects($this->any())->method('getConfigurationDesignTheme')->with('area')->will($this->returnValue($this->theme));
     $this->design->expects($this->any())->method('getThemePath')->with($this->theme)->will($this->returnValue('theme'));
     $this->themeList->expects($this->any())->method('getThemeByFullPath')->will($this->returnValue($this->theme));
 }
コード例 #24
0
 /**
  * Get theme model based on the information from asset
  *
  * @param LocalInterface $asset
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 protected function getTheme(LocalInterface $asset)
 {
     $context = $asset->getContext();
     if ($context instanceof FallbackContext) {
         return $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath());
     }
     return $this->design->getDesignTheme();
 }
コード例 #25
0
 /**
  * @magentoConfigFixture current_store design/theme/theme_id one
  * @magentoConfigFixture fixturestore_store design/theme/theme_id two
  * @magentoDataFixture Magento/Core/_files/store.php
  */
 public function testGetConfigurationDesignThemeStore()
 {
     $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\StoreManagerInterface')->getStore()->getId();
     $this->assertEquals('one', $this->_model->getConfigurationDesignTheme());
     $this->assertEquals('one', $this->_model->getConfigurationDesignTheme(null, array('store' => $storeId)));
     $this->assertEquals('one', $this->_model->getConfigurationDesignTheme('frontend', array('store' => $storeId)));
     $this->assertEquals('two', $this->_model->getConfigurationDesignTheme(null, array('store' => 'fixturestore')));
     $this->assertEquals('two', $this->_model->getConfigurationDesignTheme('frontend', array('store' => 'fixturestore')));
 }
コード例 #26
0
 /**
  * Declare calls expectation for setConfig() method
  */
 protected function expectsSetConfig($themeId, $localeCode = 'en_US')
 {
     $this->locale->expects($this->any())->method('getLocaleCode')->will($this->returnValue($localeCode));
     $scope = new \Magento\Framework\Object(['code' => 'frontendCode', 'id' => 1]);
     $scopeAdmin = new \Magento\Framework\Object(['code' => 'adminCode', 'id' => 0]);
     $this->scopeResolver->expects($this->any())->method('getScope')->will($this->returnValueMap([[null, $scope], ['admin', $scopeAdmin]]));
     $designTheme = new \Magento\Framework\Object(['id' => $themeId]);
     $this->viewDesign->expects($this->any())->method('getDesignTheme')->will($this->returnValue($designTheme));
 }
コード例 #27
0
 /**
  * @return void
  */
 public function testGetUrl()
 {
     $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false);
     $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']);
     $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock();
     $assetMock->expects($this->any())->method('getUrl')->willReturn('some url');
     $this->fileFactoryMock->expects($this->exactly(2))->method('create')->with(['source' => $this->sourceMock, 'context' => '', 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock);
     $this->assertEquals('some url', $this->repository->getUrl('test/file.js'));
     $this->assertEquals('some url', $this->repository->getUrlWithParams('test/file.js', []));
 }
コード例 #28
0
 /**
  * Collect files
  *
  * @param string|null $searchPattern
  * @return array
  * @throws \Exception
  */
 public function collectFiles($searchPattern = null)
 {
     $result = [];
     if ($searchPattern === null) {
         $searchPattern = $this->searchPattern;
     }
     if ($searchPattern === null) {
         throw new \Exception('Search pattern cannot be empty.');
     }
     $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern);
     foreach ($files as $file) {
         $fullFileName = $file->getFileName();
         $fileDir = dirname($fullFileName);
         $fileName = basename($fullFileName);
         $dirRead = $this->readFactory->create($fileDir);
         $result[$fullFileName] = $dirRead->readFile($fileName);
     }
     return $result;
 }
コード例 #29
0
 /**
  * @covers \Magento\Cms\Helper\Page::renderPageExtended
  * @param integer|null $pageId
  * @param integer|null $internalPageId
  * @param integer $pageLoadResultIndex
  * @param string $customPageLayout
  * @param string $handle
  * @param string $customLayoutUpdateXml
  * @param string $layoutUpdate
  * @param boolean $expectedResult
  *
  * @dataProvider renderPageExtendedDataProvider
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testRenderPageExtended($pageId, $internalPageId, $pageLoadResultIndex, $customPageLayout, $handle, $customLayoutUpdateXml, $layoutUpdate, $expectedResult)
 {
     $storeId = 321;
     $customThemeFrom = 'customThemeFrom';
     $customThemeTo = 'customThemeTo';
     $isScopeDateInInterval = true;
     $customTheme = 'customTheme';
     $pageLayout = 'pageLayout';
     $pageIdentifier = 111;
     $layoutUpdateXml = 'layoutUpdateXml';
     $contentHeading = 'contentHeading';
     $escapedContentHeading = 'escapedContentHeading';
     $defaultGroup = 'defaultGroup';
     $pageLoadResultCollection = [null, $this->pageMock];
     $this->pageMock->expects($this->any())->method('getId')->willReturn($internalPageId);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId);
     $this->pageMock->expects($this->any())->method('setStoreId')->with($storeId)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('load')->with($pageId)->willReturn($pageLoadResultCollection[$pageLoadResultIndex]);
     $this->pageMock->expects($this->any())->method('getCustomThemeFrom')->willReturn($customThemeFrom);
     $this->pageMock->expects($this->any())->method('getCustomThemeTo')->willReturn($customThemeTo);
     $this->localeDateMock->expects($this->any())->method('isScopeDateInInterval')->with(null, $customThemeFrom, $customThemeTo)->willReturn($isScopeDateInInterval);
     $this->pageMock->expects($this->any())->method('getCustomTheme')->willReturn($customTheme);
     $this->designMock->expects($this->any())->method('setDesignTheme')->with($customTheme)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getPageLayout')->willReturn($pageLayout);
     $this->pageMock->expects($this->any())->method('getCustomPageLayout')->willReturn($customPageLayout);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('setPageLayout')->with($handle)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('initLayout')->willReturnSelf();
     $this->resultPageMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->any())->method('getUpdate')->willReturn($this->layoutProcessorMock);
     $this->layoutProcessorMock->expects($this->any())->method('addHandle')->with('cms_page_view')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getIdentifier')->willReturn($pageIdentifier);
     $this->viewMock->expects($this->any())->method('addPageLayoutHandles')->with(['id' => $pageIdentifier])->willReturn(true);
     $this->eventManagerMock->expects($this->any())->method('dispatch')->with('cms_page_render', ['page' => $this->pageMock, 'controller_action' => $this->actionMock]);
     $this->viewMock->expects($this->any())->method('loadLayoutUpdates')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getCustomLayoutUpdateXml')->willReturn($customLayoutUpdateXml);
     $this->pageMock->expects($this->any())->method('getLayoutUpdateXml')->willReturn($layoutUpdateXml);
     $this->layoutProcessorMock->expects($this->any())->method('addUpdate')->with($layoutUpdate)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('generateLayoutXml')->willReturnSelf();
     $this->viewMock->expects($this->any())->method('generateLayoutBlocks')->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getBlock')->with('page_content_heading')->willReturn($this->blockMock);
     $this->pageMock->expects($this->any())->method('getContentHeading')->willReturn($contentHeading);
     $this->escaperMock->expects($this->any())->method('escapeHtml')->with($contentHeading)->willReturn($escapedContentHeading);
     $this->blockMock->expects($this->any())->method('setContentHeading')->with($escapedContentHeading)->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getMessagesBlock')->willReturn($this->messagesBlockMock);
     $this->messageManagerMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup);
     $this->messagesBlockMock->expects($this->any())->method('addStorageType')->with($defaultGroup);
     $this->messageManagerMock->expects($this->any())->method('getMessages')->with(true)->willReturn($this->messageCollectionMock);
     $this->messagesBlockMock->expects($this->any())->method('addMessages')->with($this->messageCollectionMock)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('renderLayout')->willReturnSelf();
     $this->assertEquals($expectedResult, $this->object->renderPageExtended($this->actionMock, $pageId));
 }
コード例 #30
0
ファイル: Config.php プロジェクト: vasiljok/magento2
 /**
  * Get aggregated distributed configuration
  *
  * @return string
  */
 public function getConfig()
 {
     $distributedConfig = '';
     $baseConfig = $this->getBaseConfig();
     $customConfigFiles = $this->fileSource->getFiles($this->design->getDesignTheme(), self::CONFIG_FILE_NAME);
     foreach ($customConfigFiles as $file) {
         $config = $this->baseDir->readFile($this->baseDir->getRelativePath($file->getFilename()));
         $distributedConfig .= str_replace(['%config%', '%context%'], [$config, $file->getModule()], self::PARTIAL_CONFIG_TEMPLATE);
     }
     $fullConfig = str_replace(['%function%', '%base%', '%usages%'], [$distributedConfig, $baseConfig], self::FULL_CONFIG_TEMPLATE);
     return $fullConfig;
 }