@@ -13,10 +13,11 @@ class GetPriceConfigurationObserverTest extends \PHPUnit_Framework_TestCase
13
13
/**
14
14
* Tests the methods that rely on the ScopeConfigInterface object to provide their return values
15
15
* @dataProvider getPriceConfigurationProvider
16
+ * @param bool $hasWeeeAttributes
16
17
* @param array $testArray
17
18
* @param array $expectedArray
18
19
*/
19
- public function testGetPriceConfiguration ($ testArray , $ expectedArray )
20
+ public function testGetPriceConfiguration ($ hasWeeeAttributes , $ testArray , $ expectedArray )
20
21
{
21
22
$ configObj = new \Magento \Framework \DataObject (
22
23
[
@@ -74,15 +75,21 @@ public function testGetPriceConfiguration($testArray, $expectedArray)
74
75
->with ('current_product ' )
75
76
->will ($ this ->returnValue ($ product ));
76
77
77
- $ weeeHelper ->expects ($ this ->any ())
78
- ->method ('getWeeeAttributesForBundle ' )
79
- ->will ($ this ->returnValue ([
80
- 1 => ['fpt1 ' => $ weeeObject1 ],
81
- 2 => [
82
- 'fpt1 ' =>$ weeeObject1 ,
83
- 'fpt2 ' => $ weeeObject2
84
- ]
85
- ]));
78
+ if ($ hasWeeeAttributes ) {
79
+ $ weeeHelper ->expects ($ this ->any ())
80
+ ->method ('getWeeeAttributesForBundle ' )
81
+ ->will ($ this ->returnValue ([
82
+ 1 => ['fpt1 ' => $ weeeObject1 ],
83
+ 2 => [
84
+ 'fpt1 ' => $ weeeObject1 ,
85
+ 'fpt2 ' => $ weeeObject2
86
+ ]
87
+ ]));
88
+ } else {
89
+ $ weeeHelper ->expects ($ this ->any ())
90
+ ->method ('getWeeeAttributesForBundle ' )
91
+ ->will ($ this ->returnValue (null ));
92
+ }
86
93
87
94
$ objectManager = new ObjectManager ($ this );
88
95
/** @var \Magento\Weee\Observer\GetPriceConfigurationObserver $weeeObserverObject */
@@ -105,31 +112,24 @@ public function testGetPriceConfiguration($testArray, $expectedArray)
105
112
public function getPriceConfigurationProvider ()
106
113
{
107
114
return [
108
- [
115
+ "basic " => [
116
+ 'hasWeeeAttributes ' => true ,
109
117
'testArray ' => [
110
118
[
111
119
[
112
120
'optionId ' => 1 ,
113
121
'prices ' =>
114
122
[
115
- 'finalPrice ' => [
116
- 'amount ' => 31.50 ,
117
- ],
118
- 'basePrice ' => [
119
- 'amount ' => 33.50 ,
120
- ],
123
+ 'finalPrice ' => ['amount ' => 31.50 ],
124
+ 'basePrice ' => ['amount ' => 33.50 ],
121
125
],
122
126
],
123
127
[
124
128
'optionId ' => 2 ,
125
129
'prices ' =>
126
130
[
127
- 'finalPrice ' =>[
128
- 'amount ' => 331.50 ,
129
- ],
130
- 'basePrice ' => [
131
- 'amount ' => 333.50 ,
132
- ],
131
+ 'finalPrice ' =>['amount ' => 331.50 ],
132
+ 'basePrice ' => ['amount ' => 333.50 ],
133
133
],
134
134
],
135
135
],
@@ -140,53 +140,35 @@ public function getPriceConfigurationProvider()
140
140
'optionId ' => 1 ,
141
141
'prices ' =>
142
142
[
143
- 'finalPrice ' => [
144
- 'amount ' => 31.50 ,
145
- ],
146
- 'basePrice ' => [
147
- 'amount ' => 33.50 ,
148
- ],
149
- 'weeePrice ' => [
150
- 'amount ' => 46.5 ,
151
- ],
152
- 'weeePricefpt1 ' => [
153
- 'amount ' => 15 ,
154
- ],
143
+ 'finalPrice ' => ['amount ' => 31.50 ],
144
+ 'basePrice ' => ['amount ' => 33.50 ],
145
+ 'weeePrice ' => ['amount ' => 46.5 ],
146
+ 'weeePricefpt1 ' => ['amount ' => 15 ],
155
147
],
156
148
],
157
149
[
158
150
'optionId ' => 2 ,
159
151
'prices ' =>
160
152
[
161
- 'finalPrice ' =>[
162
- 'amount ' => 331.50 ,
163
- ],
164
- 'basePrice ' => [
165
- 'amount ' => 333.50 ,
166
- ],
167
- 'weeePrice ' => [
168
- 'amount ' => 362.5 ,
169
- ],
170
- 'weeePricefpt1 ' => [
171
- 'amount ' => 15 ,
172
- ],
173
- 'weeePricefpt2 ' => [
174
- 'amount ' => 16 ,
175
- ],
153
+ 'finalPrice ' =>['amount ' => 331.50 ],
154
+ 'basePrice ' => ['amount ' => 333.50 ],
155
+ 'weeePrice ' => ['amount ' => 362.5 ],
156
+ 'weeePricefpt1 ' => ['amount ' => 15 ],
157
+ 'weeePricefpt2 ' => ['amount ' => 16 ],
176
158
],
177
159
],
178
160
],
179
161
],
180
162
],
181
- [
163
+
164
+ "layered, with extra keys " => [
165
+ 'hasWeeeAttributes ' => true ,
182
166
'testArray ' => [
183
167
[
184
168
[
185
169
'prices ' =>
186
170
[
187
- 'finalPrice ' => [
188
- 'amount ' => 31.50 ,
189
- ],
171
+ 'finalPrice ' => ['amount ' => 31.50 ],
190
172
],
191
173
'somekey ' => 0 ,
192
174
],
@@ -195,9 +177,7 @@ public function getPriceConfigurationProvider()
195
177
[
196
178
'prices ' =>
197
179
[
198
- 'finalPrice ' =>[
199
- 'amount ' => 31.50 ,
200
- ],
180
+ 'finalPrice ' =>['amount ' => 321.50 ],
201
181
],
202
182
],
203
183
'otherkey ' => [ 1 , 2 , 3 ],
@@ -210,12 +190,8 @@ public function getPriceConfigurationProvider()
210
190
[
211
191
'prices ' =>
212
192
[
213
- 'finalPrice ' => [
214
- 'amount ' => 31.50 ,
215
- ],
216
- 'weeePrice ' => [
217
- 'amount ' => 31.50 ,
218
- ],
193
+ 'finalPrice ' => ['amount ' => 31.50 ],
194
+ 'weeePrice ' => ['amount ' => 31.50 ],
219
195
],
220
196
'somekey ' => 0 ,
221
197
],
@@ -224,12 +200,8 @@ public function getPriceConfigurationProvider()
224
200
[
225
201
'prices ' =>
226
202
[
227
- 'finalPrice ' =>[
228
- 'amount ' => 31.50 ,
229
- ],
230
- 'weeePrice ' => [
231
- 'amount ' => 31.50 ,
232
- ],
203
+ 'finalPrice ' =>['amount ' => 321.50 ],
204
+ 'weeePrice ' => ['amount ' => 321.50 ],
233
205
],
234
206
],
235
207
'otherkey ' => [ 1 , 2 , 3 ],
@@ -238,6 +210,35 @@ public function getPriceConfigurationProvider()
238
210
],
239
211
],
240
212
],
213
+
214
+ "no Weee attributes, expect WeeePrice to be same as FinalPrice " => [
215
+ 'hasWeeeAttributes ' => false ,
216
+ 'testArray ' => [
217
+ [
218
+ [
219
+ 'optionId ' => 1 ,
220
+ 'prices ' =>
221
+ [
222
+ 'basePrice ' => ['amount ' => 10 ],
223
+ 'finalPrice ' => ['amount ' => 11 ],
224
+ ],
225
+ ],
226
+ ],
227
+ ],
228
+ 'expectedArray ' => [
229
+ [
230
+ [
231
+ 'optionId ' => 1 ,
232
+ 'prices ' =>
233
+ [
234
+ 'basePrice ' => ['amount ' => 10 ],
235
+ 'finalPrice ' => ['amount ' => 11 ],
236
+ 'weeePrice ' => ['amount ' => 11 ],
237
+ ],
238
+ ],
239
+ ],
240
+ ],
241
+ ],
241
242
];
242
243
}
243
244
}
0 commit comments