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()); }
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); }
/** * @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()); }