Пример #1
0
 public function testGetVarValue()
 {
     $this->assertFalse($this->_model->getVarValue('Unknown', 'nonexisting'));
     $this->assertEquals('Value One', $this->_model->getVarValue('Two', 'one'));
     $this->assertEquals('Value Two', $this->_model->getVarValue('Two', 'two'));
     $this->assertEquals('Value Three', $this->_model->getVarValue('Three', 'three'));
 }
Пример #2
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);
 }
Пример #3
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testGenerate()
 {
     $imageFile = 'image.jpg';
     $imageItem = $this->objectManager->getObject('Magento\\Framework\\DataObject', ['data' => ['file' => $imageFile]]);
     $this->mediaGalleryCollection->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([$imageItem]));
     $this->product->expects($this->any())->method('getMediaGalleryImages')->willReturn($this->mediaGalleryCollection);
     $data = $this->getTestData();
     $this->config->expects($this->once())->method('getMediaEntities')->with('Magento_Catalog')->willReturn($data);
     $themeMock = $this->getMockBuilder('Magento\\Theme\\Model\\Theme')->disableOriginalConstructor()->getMock();
     $themeMock->expects($this->exactly(3))->method('getCode')->willReturn('Magento\\theme');
     $this->themeCollection->expects($this->once())->method('loadRegisteredThemes')->willReturn([$themeMock]);
     $this->viewConfig->expects($this->once())->method('getViewConfig')->with(['area' => Area::AREA_FRONTEND, 'themeModel' => $themeMock])->willReturn($this->config);
     $this->imageHelper->expects($this->exactly(3))->method('init')->will($this->returnValueMap([[$this->product, 'product_image', $this->getImageData('product_image'), $this->imageHelper], [$this->product, 'product_small_image', $this->getImageData('product_small_image'), $this->imageHelper], [$this->product, 'product_thumbnail', $this->getImageData('product_thumbnail'), $this->imageHelper]]));
     $this->imageHelper->expects($this->exactly(3))->method('setImageFile')->with($imageFile)->willReturnSelf();
     $this->imageHelper->expects($this->any())->method('keepAspectRatio')->with($data['product_image']['aspect_ratio'])->willReturnSelf();
     $this->imageHelper->expects($this->any())->method('keepFrame')->with($data['product_image']['frame'])->willReturnSelf();
     $this->imageHelper->expects($this->any())->method('keepTransparency')->with($data['product_image']['transparency'])->willReturnSelf();
     $this->imageHelper->expects($this->any())->method('constrainOnly')->with($data['product_image']['constrain'])->willReturnSelf();
     $this->imageHelper->expects($this->any())->method('backgroundColor')->with($data['product_image']['background'])->willReturnSelf();
     $this->imageHelper->expects($this->exactly(3))->method('save')->will($this->returnSelf());
     $this->model->generate($this->product);
 }
Пример #4
0
 /**
  * Save control values data
  *
  * @param array $controlsData
  * @return $this
  */
 public function saveData(array $controlsData)
 {
     $configDom = $this->_viewConfig->getDomConfigCopy()->getDom();
     $varData = $this->_prepareVarData($controlsData, $this->_controlList);
     /** @var $varsNode \DOMElement */
     foreach ($configDom->childNodes->item(0)->childNodes as $varsNode) {
         $moduleName = $varsNode->getAttribute('module');
         if (!isset($varData[$moduleName])) {
             continue;
         }
         /** @var $varNode \DOMElement */
         foreach ($varsNode->getElementsByTagName('var') as $varNode) {
             $varName = $varNode->getAttribute('name');
             if (isset($varData[$moduleName][$varName])) {
                 list($controlName, $controlValue) = $varData[$moduleName][$varName];
                 $varNode->nodeValue = $controlValue;
                 $this->_controlList[$controlName]['value'] = $controlValue;
             }
         }
     }
     $this->_saveViewConfiguration($configDom);
     $this->_eventDispatcher->dispatch('save_view_configuration', array('configuration' => $this, 'theme' => $this->_theme));
     return $this;
 }
Пример #5
0
 public function testGetExcludedDir()
 {
     $this->assertEquals(1, count($this->_model->getExcludedDir()));
 }