Beispiel #1
0
 /**
  * @return array
  */
 protected function getConfigFiles()
 {
     $configFiles = [];
     foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
         $configFiles = array_merge($configFiles, $this->fileCollector->getFilesContent($theme, 'layouts.xml'));
     }
     return $configFiles;
 }
Beispiel #2
0
 /**
  * Retrieve view configuration data
  *
  * Collect data for 'Magento_Catalog' module from /etc/view.xml files.
  *
  * @return array
  */
 protected function getData()
 {
     if (!$this->data) {
         foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
             $config = $this->viewConfig->getViewConfig(['area' => Area::AREA_FRONTEND, 'themeModel' => $theme]);
             $this->data = array_merge($this->data, $this->applyFilters($config->getVars('Magento_Catalog')));
         }
     }
     return $this->data;
 }
Beispiel #3
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());
 }
 /**
  * Test get page layouts config
  *
  * @return void
  */
 public function testGetPageLayoutsConfig()
 {
     $files1 = ['content layouts_1.xml', 'content layouts_2.xml'];
     $files2 = ['content layouts_3.xml', 'content layouts_4.xml'];
     $theme1 = $this->getMockBuilder('Magento\\Theme\\Model\\Theme\\Data')->disableOriginalConstructor()->getMock();
     $theme2 = $this->getMockBuilder('Magento\\Theme\\Model\\Theme\\Data')->disableOriginalConstructor()->getMock();
     $this->themeCollection->expects($this->any())->method('loadRegisteredThemes')->willReturn([$theme1, $theme2]);
     $this->fileCollector->expects($this->exactly(2))->method('getFilesContent')->willReturnMap([[$theme1, 'layouts.xml', $files1], [$theme2, 'layouts.xml', $files2]]);
     $config = $this->getMockBuilder('Magento\\Framework\\View\\PageLayout\\Config')->disableOriginalConstructor()->getMock();
     $this->configFactory->expects($this->once())->method('create')->with(['configFiles' => array_merge($files1, $files2)])->willReturn($config);
     $this->assertSame($config, $this->builder->getPageLayoutsConfig());
 }
Beispiel #5
0
 public function testGenerate()
 {
     $imageFile = 'image.jpg';
     $imageItem = $this->objectManager->getObject('Magento\\Framework\\Object', ['data' => ['file' => $imageFile]]);
     $this->mediaGalleryCollection->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([$imageItem]));
     $this->product->expects($this->any())->method('getMediaGalleryImages')->willReturn($this->mediaGalleryCollection);
     $this->config->expects($this->once())->method('getVars')->with('Magento_Catalog')->willReturn($this->getTestData());
     $this->viewConfig->expects($this->once())->method('getViewConfig')->with(['area' => Area::AREA_FRONTEND, 'themeModel' => 'Magento\\theme'])->willReturn($this->config);
     $this->themeCollection->expects($this->once())->method('loadRegisteredThemes')->willReturn(['Magento\\theme']);
     $this->imageHelper->expects($this->exactly(3))->method('init')->will($this->returnValueMap([[$this->product, 'image', $imageFile, $this->imageHelper], [$this->product, 'small_image', $imageFile, $this->imageHelper], [$this->product, 'thumbnail', $imageFile, $this->imageHelper]]));
     $this->imageHelper->expects($this->exactly(3))->method('resize')->will($this->returnValueMap([[300, 300, $this->imageHelper], [200, 200, $this->imageHelper], [100, 100, $this->imageHelper]]));
     $this->imageHelper->expects($this->exactly(3))->method('save')->will($this->returnSelf());
     $this->model->generate($this->product);
 }
Beispiel #6
0
 /**
  * @test
  * @return void
  */
 public function testHasChildThemes()
 {
     $this->_model->setId(1);
     $this->resourceCollection->expects($this->once())->method('addTypeFilter')->with(Theme::TYPE_VIRTUAL)->willReturnSelf();
     $this->resourceCollection->expects($this->once())->method('addFieldToFilter')->with('parent_id', ['eq' => 1])->willReturnSelf();
     $this->resourceCollection->expects($this->once())->method('getSize')->willReturn(10);
     $this->assertTrue($this->_model->hasChildThemes());
 }
Beispiel #7
0
 /**
  * Get virtual theme title
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return string
  */
 protected function _getVirtualThemeTitle($theme)
 {
     $themeCopyCount = $this->_themeCollection->addAreaFilter(\Magento\Framework\App\Area::AREA_FRONTEND)->addTypeFilter(\Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL)->addFilter('parent_id', $theme->getId())->count();
     $title = sprintf("%s - %s #%s", $theme->getThemeTitle(), __('Copy'), $themeCopyCount + 1);
     return $title;
 }
 /**
  * Add area filter
  *
  * @return \Magento\Theme\Model\Resource\Theme\Collection
  */
 protected function _initSelect()
 {
     \Magento\Theme\Model\Resource\Theme\Collection::_initSelect();
     $this->filterVisibleThemes()->addAreaFilter(\Magento\Framework\App\Area::AREA_FRONTEND)->addParentTitle();
     return $this;
 }