From f5c557f6f3318a88dd6dcdc3d0be095394230e79 Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Tue, 25 Oct 2016 14:33:36 +0300 Subject: [PATCH 1/3] MAGETWO-60041: [Backport] Resize images mechanism is broken on frontend 2.1.3 --- app/code/Magento/Catalog/Model/Product/Image.php | 3 +-- .../Magento/Catalog/Test/Unit/Model/Product/ImageTest.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index 7d8b464db3b34..34e1ad30ad434 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -498,8 +498,7 @@ public function setBaseFile($file) $path = [ $this->_catalogProductMediaConfig->getBaseMediaPath(), 'cache', - $this->_storeManager->getStore()->getId(), - $path[] = $this->getDestinationSubdir(), + $this->getDestinationSubdir(), ]; if (!empty($this->_width) || !empty($this->_height)) { $path[] = "{$this->_width}x{$this->_height}"; 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 f4a791622f5d8..b8263eea4f553 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php @@ -180,7 +180,7 @@ public function testSetGetBaseFile() $this->image->setBaseFile('/somefile.png'); $this->assertEquals('catalog/product/somefile.png', $this->image->getBaseFile()); $this->assertEquals( - 'catalog/product/cache/1//beff4985b56e3afdbeabfc89641a4582/somefile.png', + 'catalog/product/cache//beff4985b56e3afdbeabfc89641a4582/somefile.png', $this->image->getNewFile() ); } @@ -300,7 +300,7 @@ public function testGetUrl() $this->testSetGetBaseFile(); $url = $this->image->getUrl(); $this->assertEquals( - 'http://magento.com/media/catalog/product/cache/1//beff4985b56e3afdbeabfc89641a4582/somefile.png', + 'http://magento.com/media/catalog/product/cache//beff4985b56e3afdbeabfc89641a4582/somefile.png', $url ); } From c6867c74e5ed3c76ef10631038ba107ed12fdfa8 Mon Sep 17 00:00:00 2001 From: Alex Paliarush Date: Wed, 2 Nov 2016 11:36:38 -0500 Subject: [PATCH 2/3] MAGETWO-60366: Cannot Enable Production Mode --- .../ObjectManager/Config/Compiled.php | 12 ++- .../ObjectManager/Config/CompiledTest.php | 91 +++++++++++++++++++ 2 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php b/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php index 227b9444b6061..d155432894daf 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php @@ -129,9 +129,15 @@ public function getPreference($type) */ public function extend(array $configuration) { - $this->arguments = $configuration['arguments']; - $this->virtualTypes = $configuration['instanceTypes']; - $this->preferences = $configuration['preferences']; + $this->arguments = isset($configuration['arguments']) + ? array_replace($this->arguments, $configuration['arguments']) + : $this->arguments; + $this->virtualTypes = isset($configuration['instanceTypes']) + ? array_replace($this->virtualTypes, $configuration['instanceTypes']) + : $this->virtualTypes; + $this->preferences = isset($configuration['preferences']) + ? array_replace($this->preferences, $configuration['preferences']) + : $this->preferences; } /** diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php new file mode 100644 index 0000000000000..3dd9f5065a142 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php @@ -0,0 +1,91 @@ +objectManagerHelper = new ObjectManagerHelper($this); + } + + /** + * @param array $initialData + * @param array $configuration + * @param array $expectedArguments + * @param array $expectedVirtualTypes + * @param array $expectedPreferences + * + * @dataProvider extendDataProvider + */ + public function testExtend( + array $initialData, + array $configuration, + array $expectedArguments, + array $expectedVirtualTypes, + array $expectedPreferences + ) { + /** @var CompiledConfig $compiledConfig */ + $compiledConfig = $this->objectManagerHelper->getObject(CompiledConfig::class, ['data' => $initialData]); + $compiledConfig->extend($configuration); + + foreach ($expectedArguments as $type => $arguments) { + $this->assertEquals($arguments, $compiledConfig->getArguments($type)); + } + + $this->assertEquals($expectedVirtualTypes, $compiledConfig->getVirtualTypes()); + $this->assertEquals($expectedPreferences, $compiledConfig->getPreferences()); + } + + /** + * @return array + */ + public function extendDataProvider() + { + return [ + [ + 'initialData' => [ + 'arguments' => [ + 'type1' => serialize(['argument1_1' => 'argumentValue1_1', 'argument1_2' => 'argumentValue1_2']) + ], + 'instanceTypes' => [ + 'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'instanceTypeValue2' + ], + 'preferences' => ['preference1' => 'preferenceValue1', 'preference2' => 'preferenceValue2'] + ], + 'configuration' => [ + 'arguments' => [ + 'type1' => serialize(['argument1_1' => 'newArgumentValue1_1']), + 'type2' => serialize(['argument2_1' => 'newArgumentValue2_1']) + ], + 'instanceTypes' => [ + 'instanceType2' => 'newInstanceTypeValue2', 'instanceType3' => 'newInstanceTypeValue3' + ], + 'preferences' => ['preference1' => 'newPreferenceValue1'] + ], + 'expectedArguments' => [ + 'type1' => ['argument1_1' => 'newArgumentValue1_1'], + 'type2' => ['argument2_1' => 'newArgumentValue2_1'] + ], + 'expectedVirtualTypes' => [ + 'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'newInstanceTypeValue2', + 'instanceType3' => 'newInstanceTypeValue3' + ], + 'expectedPreferences' => [ + 'preference1' => 'newPreferenceValue1', 'preference2' => 'preferenceValue2' + ] + ] + ]; + } +} From d0d1d43b0306b64398fc01e9115b4fb51b6c9c43 Mon Sep 17 00:00:00 2001 From: Alex Paliarush Date: Wed, 2 Nov 2016 13:58:28 -0500 Subject: [PATCH 3/3] MAGETWO-60366: Cannot Enable Production Mode --- .../Test/Unit/{ObjectManager => }/Config/CompiledTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lib/internal/Magento/Framework/ObjectManager/Test/Unit/{ObjectManager => }/Config/CompiledTest.php (98%) diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php similarity index 98% rename from lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php rename to lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php index 3dd9f5065a142..1fcf3176540db 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/ObjectManager/Config/CompiledTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php @@ -3,7 +3,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Test\Unit\ObjectManager\Config; +namespace Magento\Framework\ObjectManager\Test\Unit\Config; use Magento\Framework\ObjectManager\Config\Compiled as CompiledConfig; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;