/** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Cannot recognize image extension. */ public function testSaveWithoutFileExtension() { $imageContent = $this->getMockBuilder('Magento\\Framework\\Api\\Data\\ImageContentInterface')->disableOriginalConstructor()->getMock(); $imageContent->expects($this->once())->method('getBase64EncodedData')->willReturn('testImageData'); $imageContent->expects($this->once())->method('getName')->willReturn('testFileName'); $imageDataObject = $this->getMockBuilder('Magento\\Framework\\Api\\AttributeValue')->disableOriginalConstructor()->getMock(); $imageDataObject->expects($this->once())->method('getValue')->willReturn($imageContent); $imageData = $this->getMockForAbstractClass('Magento\\Framework\\Api\\CustomAttributesDataInterface'); $imageData->expects($this->once())->method('getCustomAttributes')->willReturn([]); $this->dataObjectHelperMock->expects($this->once())->method('getCustomAttributeValueByType')->willReturn([$imageDataObject]); $this->contentValidatorMock->expects($this->once())->method('isValid')->willReturn(true); $this->assertEquals($imageData, $this->imageProcessor->save($imageData, 'testEntityType')); }
/** * @param ImageContentInterface $imageContent * @return string */ protected function saveFile(ImageContentInterface $imageContent) { $uri = $this->filesystem->getUri(DirectoryList::MEDIA); $filePath = $this->imageProcessor->processImageContent($this->destinationFolder, $imageContent); return $uri . $this->destinationFolder . $filePath; }
/** * @param ImageContentInterface $imageContent * @return string */ protected function saveFile(ImageContentInterface $imageContent) { $filePath = $this->imageProcessor->processImageContent($this->destinationFolder, $imageContent); return $this->destinationFolder . $filePath; }