Skip to content

Commit

Permalink
Merge pull request #563 from magento-okapis
Browse files Browse the repository at this point in the history
Fixed issues:
 - MAGETWO-60366 Cannot Enable Production Mode
 - MAGETWO-60041 [Backport] Resize images mechanism is broken on frontend 2.1.3
  • Loading branch information
Oleksii Korshenko authored Nov 2, 2016
2 parents d83dd4c + 34fed9a commit 5e86fa1
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 7 deletions.
3 changes: 1 addition & 2 deletions app/code/Magento/Catalog/Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
Expand Down Expand Up @@ -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
);
}
Expand Down
12 changes: 9 additions & 3 deletions lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\ObjectManager\Test\Unit\Config;

use Magento\Framework\ObjectManager\Config\Compiled as CompiledConfig;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

class CompiledTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManagerHelper
*/
private $objectManagerHelper;

protected function setUp()
{
$this->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'
]
]
];
}
}

0 comments on commit 5e86fa1

Please sign in to comment.