コード例 #1
0
    public function testGetViewConfig()
    {
        $themeCode = 2;

        $themeMock = $this->getMock(
            'Magento\Theme\Model\Theme',
            ['getCode'],
            [],
            '',
            false
        );
        $themeMock->expects($this->atLeastOnce())
            ->method('getCode')
            ->will($this->returnValue($themeCode));
        $params = [
            'themeModel' => $themeMock,
            'area'       => 'frontend'
        ];
        $this->repositoryMock->expects($this->atLeastOnce())
            ->method('updateDesignParams')
            ->with($this->equalTo($params))
            ->will($this->returnSelf());
        $configViewMock = $this->getMock('Magento\Framework\Config\View', [], [], '', false);
        $this->viewConfigFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($configViewMock);
        $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params));
        // lazy load test
        $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params));
    }
コード例 #2
0
ファイル: PreviewTest.php プロジェクト: nblair/magescotch
 public function testExecuteInternal()
 {
     $this->viewMock->expects($this->once())->method('getPage')->willReturn($this->pageMock);
     $this->pageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->willReturnSelf();
     $this->assertNull($this->object->executeInternal());
 }
コード例 #3
0
ファイル: ConfigTest.php プロジェクト: nblair/magescotch
 public function testGetViewConfig()
 {
     $themeMock = $this->getMock(
         'Magento\Theme\Model\Theme',
         ['getCode', 'getCustomization', 'getCustomViewConfigPath'],
         [],
         '',
         false
     );
     $themeMock->expects($this->atLeastOnce())
         ->method('getCode')
         ->will($this->returnValue(2));
     $themeMock->expects($this->once())
         ->method('getCustomization')
         ->will($this->returnSelf());
     $themeMock->expects($this->once())
         ->method('getCustomViewConfigPath')
         ->will($this->returnValue(''));
     $params = ['themeModel' => $themeMock];
     $configFile = 'config.xml';
     $this->repositoryMock->expects($this->atLeastOnce())
         ->method('updateDesignParams')
         ->with($this->equalTo($params))
         ->will($this->returnSelf());
     $iterator = $this->getMock('Magento\Framework\Config\FileIterator', [], [], '', false);
     $iterator->expects($this->once())
         ->method('toArray')
         ->will($this->returnValue([]));
     $this->readerMock->expects($this->once())
         ->method('getConfigurationFiles')
         ->with($this->equalTo(basename(\Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME)))
         ->will($this->returnValue($iterator));
     $this->directoryReadMock->expects($this->once())
         ->method('isExist')
         ->with($this->anything())
         ->will($this->returnValue(true));
     $this->fileSystemMock->expects($this->once())
         ->method('getFilename')
         ->with($this->equalTo(\Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME), $params)
         ->will($this->returnValue($configFile));
     $this->directoryReadMock->expects($this->any())
         ->method('getRelativePath')
         ->with($this->equalTo($configFile))
         ->will($this->returnArgument(0));
     $xmlData = '<view><vars module="Magento_Catalog"><var name="test">1</var></vars></view>';
     $this->directoryReadMock->expects($this->once())
         ->method('readFile')
         ->with($this->equalTo($configFile))
         ->will($this->returnValue($xmlData));
     $configViewMock = $this->getMock('Magento\Framework\Config\View', [], [], '', false);
     $this->viewConfigFactoryMock->expects($this->once())
         ->method('create')
         ->with([$configFile => $xmlData])
         ->willReturn($configViewMock);
     $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params));
     // lazy load test
     $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params));
 }
コード例 #4
0
 protected function generateImageConfig()
 {
     $themeMock = $this->getMock('\\Magento\\Theme\\Model\\Theme', [], [], '', false);
     $themesArrayMock = [$themeMock];
     $this->themeCollectionMock->expects($this->any())->method('loadRegisteredThemes')->willReturn($themesArrayMock);
     $configMock = $this->getMock('\\Magento\\Framework\\Config\\View', [], [], '', false);
     $this->viewConfigMock->expects($this->atLeastOnce())->method('getViewConfig')->willReturn($configMock);
     $imageConfig = ['swatch_image' => ['width' => 30, 'height' => 20], 'swatch_thumb' => ['width' => 110, 'height' => 90]];
     $configMock->expects($this->any())->method('getMediaEntities')->willReturn($imageConfig);
 }
コード例 #5
0
 /**
  * @dataProvider dataForVideoBackground
  */
 public function testGetVideoAutoRestartAttribute($expectedResult)
 {
     $this->viewConfigMock->expects($this->once())->method('getMediaAttributes')->willReturn($expectedResult);
     $this->mediaHelperObject->getVideoAutoRestartAttribute();
 }