Skip to content

Commit 7f48d52

Browse files
MAGETWO-60428: Production mode is not enabled on Bamboo - 2.0
1 parent ee0228a commit 7f48d52

File tree

2 files changed

+149
-6
lines changed

2 files changed

+149
-6
lines changed

lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2016 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Framework\ObjectManager\Config;
87

8+
use Magento\Framework\ObjectManager\ConfigInterface;
99
use Magento\Framework\ObjectManager\ConfigCacheInterface;
1010
use Magento\Framework\ObjectManager\RelationsInterface;
1111

12-
class Compiled implements \Magento\Framework\ObjectManager\ConfigInterface
12+
class Compiled implements ConfigInterface
1313
{
1414
/**
1515
* @var array
@@ -76,7 +76,7 @@ public function getArguments($type)
7676
}
7777
return $this->arguments[$type];
7878
} else {
79-
return [['_i_' => 'Magento\Framework\ObjectManagerInterface']];
79+
return [['_i_' => \Magento\Framework\ObjectManagerInterface::class]];
8080
}
8181
}
8282

@@ -129,9 +129,23 @@ public function getPreference($type)
129129
*/
130130
public function extend(array $configuration)
131131
{
132-
$this->arguments = $configuration['arguments'];
133-
$this->virtualTypes = $configuration['instanceTypes'];
134-
$this->preferences = $configuration['preferences'];
132+
$this->arguments = isset($configuration['arguments'])
133+
? array_replace(
134+
$this->arguments ?: [],
135+
$configuration['arguments']
136+
) : $this->arguments;
137+
138+
$this->virtualTypes = isset($configuration['instanceTypes'])
139+
? array_replace(
140+
$this->virtualTypes ?: [],
141+
$configuration['instanceTypes']
142+
) : $this->virtualTypes;
143+
144+
$this->preferences = isset($configuration['preferences'])
145+
? array_replace(
146+
$this->preferences ?: [],
147+
$configuration['preferences']
148+
) : $this->preferences;
135149
}
136150

137151
/**
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Test\Unit\ObjectManager\Config;
7+
8+
use Magento\Framework\ObjectManager\Config\Compiled as CompiledConfig;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
10+
11+
class CompiledTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var ObjectManagerHelper
15+
*/
16+
private $objectManagerHelper;
17+
18+
protected function setUp()
19+
{
20+
$this->objectManagerHelper = new ObjectManagerHelper($this);
21+
}
22+
23+
/**
24+
* @param array $initialData
25+
* @param array $configuration
26+
* @param array $expectedArguments
27+
* @param array $expectedVirtualTypes
28+
* @param array $expectedPreferences
29+
*
30+
* @dataProvider extendDataProvider
31+
*/
32+
public function testExtend(
33+
array $initialData,
34+
array $configuration,
35+
array $expectedArguments,
36+
array $expectedVirtualTypes,
37+
array $expectedPreferences
38+
) {
39+
/** @var CompiledConfig $compiledConfig */
40+
$compiledConfig = $this->objectManagerHelper->getObject(CompiledConfig::class, ['data' => $initialData]);
41+
$compiledConfig->extend($configuration);
42+
43+
foreach ($expectedArguments as $type => $arguments) {
44+
$this->assertEquals($arguments, $compiledConfig->getArguments($type));
45+
}
46+
47+
$this->assertEquals($expectedVirtualTypes, $compiledConfig->getVirtualTypes());
48+
$this->assertEquals($expectedPreferences, $compiledConfig->getPreferences());
49+
}
50+
51+
/**
52+
* @return array
53+
*/
54+
public function extendDataProvider()
55+
{
56+
return [
57+
[
58+
'initialData' => [
59+
'arguments' => [
60+
'type1' => serialize(['argument1_1' => 'argumentValue1_1', 'argument1_2' => 'argumentValue1_2'])
61+
],
62+
'instanceTypes' => [
63+
'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'instanceTypeValue2'
64+
],
65+
'preferences' => [
66+
'preference1' => 'preferenceValue1',
67+
'preference2' => 'preferenceValue2'
68+
]
69+
],
70+
'configuration' => [
71+
'arguments' => [
72+
'type1' => serialize(['argument1_1' => 'newArgumentValue1_1']),
73+
'type2' => serialize(['argument2_1' => 'newArgumentValue2_1'])
74+
],
75+
'instanceTypes' => [
76+
'instanceType2' => 'newInstanceTypeValue2',
77+
'instanceType3' => 'newInstanceTypeValue3'
78+
],
79+
'preferences' => [
80+
'preference1' => 'newPreferenceValue1'
81+
]
82+
],
83+
'expectedArguments' => [
84+
'type1' => ['argument1_1' => 'newArgumentValue1_1'],
85+
'type2' => ['argument2_1' => 'newArgumentValue2_1']
86+
],
87+
'expectedVirtualTypes' => [
88+
'instanceType1' => 'instanceTypeValue1',
89+
'instanceType2' => 'newInstanceTypeValue2',
90+
'instanceType3' => 'newInstanceTypeValue3'
91+
],
92+
'expectedPreferences' => [
93+
'preference1' => 'newPreferenceValue1',
94+
'preference2' => 'preferenceValue2'
95+
]
96+
],
97+
98+
[
99+
'initialData' => [
100+
'arguments' => null,
101+
'instanceTypes' => null,
102+
'preferences' => null
103+
],
104+
'configuration' => [
105+
'arguments' => [
106+
'type1' => serialize(['argument1_1' => 'newArgumentValue1_1']),
107+
'type2' => serialize(['argument2_1' => 'newArgumentValue2_1'])
108+
],
109+
'instanceTypes' => [
110+
'instanceType2' => 'newInstanceTypeValue2',
111+
'instanceType3' => 'newInstanceTypeValue3'
112+
],
113+
'preferences' => ['preference1' => 'newPreferenceValue1']
114+
],
115+
'expectedArguments' => [
116+
'type1' => ['argument1_1' => 'newArgumentValue1_1'],
117+
'type2' => ['argument2_1' => 'newArgumentValue2_1']
118+
],
119+
'expectedVirtualTypes' => [
120+
'instanceType2' => 'newInstanceTypeValue2',
121+
'instanceType3' => 'newInstanceTypeValue3'
122+
],
123+
'expectedPreferences' => [
124+
'preference1' => 'newPreferenceValue1'
125+
]
126+
]
127+
];
128+
}
129+
}

0 commit comments

Comments
 (0)