Skip to content

Commit f5d99fe

Browse files
author
Maksym Aposov
committed
MAGETWO-51116: There is no ability to add product with file custom option to shopping cart as guest user using API
1 parent 2fdd82e commit f5d99fe

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase
1616
protected $model;
1717

1818
/**
19-
* @var \Magento\Framework\ObjectManager
19+
* @var \Magento\Framework\ObjectManagerInterface
2020
*/
2121
protected $objectManager;
2222

@@ -164,11 +164,13 @@ protected function getProductOption(array $options = [])
164164
*/
165165
protected function getOptionValue()
166166
{
167-
$file = 'var/tmp/magento_small_image.jpg';
167+
/** @var \Magento\Catalog\Model\Product\Media\Config $config */
168+
$config = $this->objectManager->get('Magento\Catalog\Model\Product\Media\Config');
169+
$file = $config->getBaseTmpMediaPath() . '/magento_small_image.jpg';
168170

169-
/** @var \Magento\Framework\App\Filesystem $filesystem */
171+
/** @var \Magento\Framework\Filesystem $filesystem */
170172
$filesystem = $this->objectManager->get('Magento\Framework\Filesystem');
171-
$tmpDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
173+
$tmpDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
172174
$filePath = $tmpDirectory->getAbsolutePath($file);
173175

174176
return [

dev/tests/integration/testsuite/Magento/Catalog/_files/validate_image_info.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
88

99
/** @var \Magento\Framework\Filesystem $filesystem */
10-
$filesystem = $objectManager->create('Magento\Framework\Filesystem');
10+
$filesystem = $objectManager->get('Magento\Framework\Filesystem');
11+
12+
/** @var Magento\Catalog\Model\Product\Media\Config $config */
13+
$config = $objectManager->get('Magento\Catalog\Model\Product\Media\Config');
1114

1215
/** @var $tmpDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */
13-
$tmpDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
14-
$tmpDirectory->create('var/tmp');
16+
$tmpDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
17+
$tmpDirectory->create($config->getBaseTmpMediaPath());
1518

16-
$targetTmpFilePath = $tmpDirectory->getAbsolutePath('var/tmp/magento_small_image.jpg');
19+
$targetTmpFilePath = $tmpDirectory->getAbsolutePath($config->getBaseTmpMediaPath() . '/magento_small_image.jpg');
1720
copy(__DIR__ . '/magento_small_image.jpg', $targetTmpFilePath);
1821
// Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir

dev/tests/integration/testsuite/Magento/Catalog/_files/validate_image_info_rollback.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
/** @var \Magento\Framework\Filesystem $filesystem */
1010
$filesystem = $objectManager->create('Magento\Framework\Filesystem');
1111

12+
/** @var Magento\Catalog\Model\Product\Media\Config $config */
13+
$config = $objectManager->get('Magento\Catalog\Model\Product\Media\Config');
14+
1215
/** @var $tmpDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */
13-
$tmpDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::TMP);
14-
$tmpDirectory->create($tmpDirectory->getAbsolutePath());
16+
$tmpDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
1517

16-
$targetTmpFilePath = $tmpDirectory->getAbsolutePath('magento_small_image.jpg');
18+
$targetTmpFilePath = $tmpDirectory->getAbsolutePath($config->getBaseTmpMediaPath() . '/magento_small_image.jpg');
1719
if (file_exists($targetTmpFilePath)) {
1820
unlink($targetTmpFilePath);
1921
}

0 commit comments

Comments
 (0)