diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index 34b145ac113f481fdf9ba117c82d5c7aad635aef..769faa682f422b569dd6673df819f05d7371aeb8 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -468,9 +468,6 @@ class Image extends \Magento\Framework\Model\AbstractModel public function setBaseFile($file) { $this->_isBaseFilePlaceholder = false; - if ($file == 'no_selection') { - return $this; - } $this->imageAsset = $this->getViewAssetImageFactory()->create( [ @@ -478,7 +475,7 @@ class Image extends \Magento\Framework\Model\AbstractModel 'filePath' => $file, ] ); - if (!$this->_fileExists($this->imageAsset->getSourceFile()) + if ($file == 'no_selection' || !$this->_fileExists($this->imageAsset->getSourceFile()) || !$this->_checkMemory($this->imageAsset->getSourceFile()) ) { $this->_isBaseFilePlaceholder = true; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php index e4cae1d88eb99fbea7b6f7772767d6a5c56b257e..8ee875dad17b1c8fb09a99449c039825f9e1344c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php @@ -254,8 +254,10 @@ class ImageTest extends \PHPUnit_Framework_TestCase public function testSetBaseNoSelectionFile() { + $this->viewAssetPlaceholderFactory->expects($this->once())->method('create')->willReturn($this->imageAsset); + $this->imageAsset->expects($this->any())->method('getSourceFile')->willReturn('Default Placeholder Path'); $this->image->setBaseFile('no_selection'); - $this->assertNull($this->image->getBaseFile()); + $this->assertEquals('Default Placeholder Path', $this->image->getBaseFile()); } public function testSetGetImageProcessor() @@ -373,6 +375,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase public function testGetUrlNoSelection() { + $this->viewAssetPlaceholderFactory->expects($this->once())->method('create')->willReturn($this->imageAsset); $this->imageAsset->expects($this->any())->method('getUrl')->will($this->returnValue('Default Placeholder URL')); $this->image->setBaseFile('no_selection'); $this->assertEquals('Default Placeholder URL', $this->image->getUrl());