Ejemplo n.º 1
0
 public function testSetWatermark()
 {
     $website = $this->getMockBuilder('\\Magento\\Store\\Model\\Website')->disableOriginalConstructor()->setMethods(['getId', '__sleep', '__wakeup'])->getMock();
     $website->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website));
     $this->mediaDirectory->expects($this->at(3))->method('isExist')->with('catalog/product/watermark//somefile.png')->will($this->returnValue(true));
     $absolutePath = dirname(dirname(__DIR__)) . '/_files/catalog/product/watermark/somefile.png';
     $this->mediaDirectory->expects($this->any())->method('getAbsolutePath')->with('catalog/product/watermark//somefile.png')->will($this->returnValue($absolutePath));
     $imageProcessor = $this->getMockBuilder('Magento\\Framework\\Image')->disableOriginalConstructor()->setMethods(['keepAspectRatio', 'keepFrame', 'keepTransparency', 'constrainOnly', 'backgroundColor', 'quality', 'setWatermarkPosition', 'setWatermarkImageOpacity', 'setWatermarkWidth', 'setWatermarkHeight', 'watermark'])->getMock();
     $imageProcessor->expects($this->once())->method('setWatermarkPosition')->with('center')->will($this->returnValue(true));
     $imageProcessor->expects($this->once())->method('setWatermarkImageOpacity')->with(50)->will($this->returnValue(true));
     $imageProcessor->expects($this->once())->method('setWatermarkWidth')->with(100)->will($this->returnValue(true));
     $imageProcessor->expects($this->once())->method('setWatermarkHeight')->with(100)->will($this->returnValue(true));
     $this->image->setImageProcessor($imageProcessor);
     $result = $this->image->setWatermark('/somefile.png', 'center', ['width' => 100, 'height' => 100], 100, 100, 50);
     $this->assertSame($this->image, $result);
 }