예제 #1
0
 /**
  * @test
  * @return void
  */
 public function testGetInheritedThemes()
 {
     $inheritedTheme = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->getMock();
     $this->_model->setParentId(10);
     $this->themeFactory->expects($this->once())->method('create')->with(10)->willReturn($inheritedTheme);
     $this->assertContainsOnlyInstancesOf('Magento\\Framework\\View\\Design\\ThemeInterface', $this->_model->getInheritedThemes());
     $this->assertCount(2, $this->_model->getInheritedThemes());
 }
 /**
  * @test
  * @param bool $storeMode
  * @param string $scope
  * @dataProvider designThemeDataProvider
  * @return void
  */
 public function testSetDefaultDesignTheme($storeMode, $scope)
 {
     $area = Design::DEFAULT_AREA;
     $this->state->expects($this->any())->method('getAreaCode')->willReturn($area);
     $this->storeManager->expects($this->once())->method('isSingleStoreMode')->willReturn($storeMode);
     $this->config->expects($this->once())->method('getValue')->with(Design::XML_PATH_THEME_ID, $scope, null)->willReturn(null);
     $this->flyweightThemeFactory->expects($this->once())->method('create')->with($this->defaultTheme, $area);
     $this->assertInstanceOf(get_class($this->model), $this->model->setDefaultDesignTheme());
 }
예제 #3
0
 protected function setUp()
 {
     $this->customizationPath = '/' . implode('/', ['var', 'theme']);
     $this->request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', [], [], '', false);
     $this->contextHelper = $this->getMock('Magento\\Framework\\App\\Helper\\Context', [], [], '', false);
     $this->directoryWrite = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $this->themeFactory = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory', [], [], '', false);
     $this->theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $this->customization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', [], [], '', false);
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWrite));
     $this->directoryWrite->expects($this->any())->method('create')->will($this->returnValue(true));
     $this->contextHelper->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->themeFactory->expects($this->any())->method('create')->will($this->returnValue($this->theme));
     $this->theme->expects($this->any())->method('getCustomization')->will($this->returnValue($this->customization));
     $this->request->expects($this->at(0))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_THEME_ID)->will($this->returnValue(6));
     $this->request->expects($this->at(1))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE)->will($this->returnValue(\Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE));
     $this->helper = new \Magento\Theme\Helper\Storage($this->contextHelper, $this->filesystem, $this->session, $this->themeFactory);
 }
예제 #4
0
 public function testExecute()
 {
     $themeId = 23;
     $theme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface', [], '', false);
     $jsFile = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\Theme\\FileInterface', [], '', false, true, true, ['setTheme', 'setFileName', 'setData', 'save']);
     $this->_request->expects($this->at(0))->method('getParam')->with('id')->willReturn($themeId);
     $this->_objectManagerMock->expects($this->at(0))->method('get')->with('Magento\\Theme\\Model\\Uploader\\Service')->WillReturn($this->serviceModel);
     $this->_objectManagerMock->expects($this->at(1))->method('get')->with('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory')->WillReturn($this->themeFactory);
     $this->_objectManagerMock->expects($this->at(2))->method('get')->with('Magento\\Framework\\View\\Design\\Theme\\Customization\\File\\Js')->WillReturn($this->customizationJs);
     $this->_objectManagerMock->expects($this->at(4))->method('get')->with('Magento\\Framework\\Json\\Helper\\Data')->WillReturn($this->jsonHelper);
     $this->themeFactory->expects($this->once())->method('create')->willReturn($theme);
     $this->serviceModel->expects($this->once())->method('uploadJsFile')->with('js_files_uploader')->willReturn(['filename' => 'filename', 'content' => 'content']);
     $this->customizationJs->expects($this->once())->method('create')->willReturn($jsFile);
     $jsFile->expects($this->once())->method('setTheme')->with($theme);
     $jsFile->expects($this->once())->method('setFileName')->with('filename');
     $jsFile->expects($this->once())->method('setData')->with('content', 'content');
     $jsFile->expects($this->once())->method('save');
     $this->_objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\View\\Design\\Theme\\CustomizationInterface', ['theme' => $theme])->willReturn($this->themeCustomization);
     $this->themeCustomization->expects($this->once())->method('getFilesByType')->with(\Magento\Framework\View\Design\Theme\Customization\File\Js::TYPE)->willReturn([$jsFile]);
     $this->themeCustomization->expects($this->once())->method('generateFileInfo')->with([$jsFile])->willReturn(['fileOne' => ['name' => 'name']]);
     $this->jsonHelper->expects($this->once())->method('jsonEncode')->with(['error' => false, 'files' => ['fileOne' => ['name' => 'name']]])->willReturn('{"error":false,"files":{"fileOne":{"name":"name"}}}');
     $this->response->expects($this->once())->method('representJson')->with('{"error":false,"files":{"fileOne":{"name":"name"}}}');
     $this->_model->execute();
 }
예제 #5
0
 /**
  * @test
  * @return void
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Theme was not found
  */
 public function testGetThemeNotFound()
 {
     $this->themeFactory->expects($this->once())->method('create')->willReturn(null);
     $helper = new \Magento\Theme\Helper\Storage($this->contextHelper, $this->filesystem, $this->session, $this->themeFactory);
     $helper->getStorageRoot();
 }
예제 #6
0
 /**
  * @test
  * @return void
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Theme id should be set
  */
 public function testGetThemeException()
 {
     $this->themeFactory->expects($this->once())->method('create')->with(null, DesignInterface::DEFAULT_AREA)->willReturn(null);
     $this->model->getTheme();
 }