Пример #1
0
 /**
  * @param string $imageId
  * @param string $imageFile
  * @param string $baseFile
  * @param string $newFile
  * @param string $destination
  * @param boolean $setImageFile
  * @param boolean $isCached
  * @param boolean $isBaseFilePlaceholder
  * @param array $resizedImageInfo
  * @dataProvider getResizedImageInfoDataProvider
  */
 public function testGetResizedImageInfo($imageId, $imageFile, $baseFile, $newFile, $destination, $setImageFile, $isCached, $isBaseFilePlaceholder, $resizedImageInfo)
 {
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->any())->method('getData')->with($destination)->willReturn($imageFile);
     $this->image->expects($this->any())->method('setBaseFile')->with($imageFile)->willReturnSelf();
     $this->image->expects($this->once())->method('getBaseFile')->willReturn($baseFile);
     $this->image->expects($this->any())->method('getDestinationSubdir')->willReturn($destination);
     $this->image->expects($this->any())->method('isCached')->willReturn($isCached);
     $this->image->expects($this->any())->method('resize')->willReturnSelf();
     $this->image->expects($this->any())->method('saveFile')->willReturnSelf();
     $this->image->expects($this->once())->method('getResizedImageInfo')->willReturn($resizedImageInfo);
     $this->image->expects($this->any())->method('isBaseFilePlaceholder')->willReturn($isBaseFilePlaceholder);
     $this->image->expects($this->any())->method('getNewFile')->willReturn($newFile);
     $this->prepareAttributes([], $imageId);
     $this->helper->init($productMock, $imageId);
     if ($setImageFile) {
         $this->helper->setImageFile($imageFile);
     }
     $result = $this->helper->getResizedImageInfo();
     $this->assertEquals($resizedImageInfo, $result);
 }
Пример #2
0
 public function testIsBaseFilePlaceholder()
 {
     $this->assertFalse($this->image->isBaseFilePlaceholder());
 }
Пример #3
0
 public function beforeSaveFile(Image $image)
 {
     $image->setQuality(self::SOURCE_QUALITY);
 }
Пример #4
0
 /**
  * @param \Magento\Catalog\Model\Product\Image $model
  * @depends testSetBaseFilePlaceholder
  */
 public function testGetUrlPlaceholder($model)
 {
     $this->assertStringMatchesFormat('http://localhost/pub/static/frontend/%s/Magento_Catalog/images/product/placeholder/image.jpg', $model->getUrl());
 }
Пример #5
0
 public function testGetImageProcessor()
 {
     $imageProcessor = $this->getMockBuilder('\\Magento\\Framework\\Image')->disableOriginalConstructor()->getMock();
     $this->factory->expects($this->once())->method('create')->will($this->returnValue($imageProcessor));
     $this->assertSame($imageProcessor, $this->image->getImageProcessor());
 }