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));
    }
Exemple #2
0
 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));
 }