@@ -157,13 +157,17 @@ protected function setUp()
157
157
}
158
158
159
159
/**
160
- * test GetProductWeeeAttributes
161
160
* @dataProvider getProductWeeeAttributesDataProvider
162
161
* @param array $weeeTaxCalculationsByEntity
163
- * @param array $expectedFptLabel
162
+ * @param mixed $websitePassed
163
+ * @param string $expectedFptLabel
164
+ * @return void
164
165
*/
165
- public function testGetProductWeeeAttributes ($ weeeTaxCalculationsByEntity , $ expectedFptLabel )
166
- {
166
+ public function testGetProductWeeeAttributes (
167
+ array $ weeeTaxCalculationsByEntity ,
168
+ $ websitePassed ,
169
+ string $ expectedFptLabel
170
+ ) {
167
171
$ product = $ this ->createMock (\Magento \Catalog \Model \Product::class);
168
172
$ website = $ this ->createMock (\Magento \Store \Model \Website::class);
169
173
$ store = $ this ->createMock (\Magento \Store \Model \Store::class);
@@ -187,28 +191,38 @@ public function testGetProductWeeeAttributes($weeeTaxCalculationsByEntity, $expe
187
191
->method ('getAttributeCodesByFrontendType ' )
188
192
->willReturn (['0 ' =>'fpt ' ]);
189
193
190
- $ store ->expects ($ this ->any ())
191
- ->method ('getId ' )
192
- ->willReturn (1 );
193
-
194
- $ product ->expects ($ this ->any ())
195
- ->method ('getId ' )
196
- ->willReturn (1 );
197
-
194
+ $ this ->storeManager ->expects ($ this ->any ())
195
+ ->method ('getWebsite ' )
196
+ ->willReturn ($ website );
198
197
$ website ->expects ($ this ->any ())
199
198
->method ('getId ' )
200
- ->willReturn (1 );
199
+ ->willReturn ($ websitePassed );
201
200
$ website ->expects ($ this ->any ())
202
201
->method ('getDefaultGroup ' )
203
202
->willReturn ($ group );
204
-
205
203
$ group ->expects ($ this ->any ())
206
204
->method ('getDefaultStore ' )
207
205
->willReturn ($ store );
206
+ $ store ->expects ($ this ->any ())
207
+ ->method ('getId ' )
208
+ ->willReturn (1 );
208
209
209
- $ this ->storeManager ->expects ($ this ->any ())
210
- ->method ('getWebsite ' )
211
- ->willReturn ($ website );
210
+ if ($ websitePassed ) {
211
+ $ product ->expects ($ this ->never ())
212
+ ->method ('getStore ' )
213
+ ->willReturn ($ store );
214
+ } else {
215
+ $ product ->expects ($ this ->once ())
216
+ ->method ('getStore ' )
217
+ ->willReturn ($ store );
218
+ $ store ->expects ($ this ->once ())
219
+ ->method ('getWebsiteId ' )
220
+ ->willReturn (1 );
221
+ }
222
+
223
+ $ product ->expects ($ this ->any ())
224
+ ->method ('getId ' )
225
+ ->willReturn (1 );
212
226
213
227
$ this ->weeeConfig ->expects ($ this ->any ())
214
228
->method ('isEnabled ' )
@@ -237,7 +251,7 @@ public function testGetProductWeeeAttributes($weeeTaxCalculationsByEntity, $expe
237
251
0 => $ weeeTaxCalculationsByEntity
238
252
]);
239
253
240
- $ result = $ this ->model ->getProductWeeeAttributes ($ product , null , null , null , true );
254
+ $ result = $ this ->model ->getProductWeeeAttributes ($ product , null , null , $ websitePassed , true );
241
255
$ this ->assertTrue (is_array ($ result ));
242
256
$ this ->assertArrayHasKey (0 , $ result );
243
257
$ obj = $ result [0 ];
@@ -312,7 +326,8 @@ public function getProductWeeeAttributesDataProvider()
312
326
'frontend_label ' => 'fpt_label_frontend ' ,
313
327
'attribute_code ' => 'fpt_code ' ,
314
328
],
315
- 'expectedFptLabel ' => 'fpt_label '
329
+ 'websitePassed ' => 1 ,
330
+ 'expectedFptLabel ' => 'fpt_label ' ,
316
331
],
317
332
'store_label_not_defined ' => [
318
333
'weeeTaxCalculationsByEntity ' => [
@@ -321,8 +336,19 @@ public function getProductWeeeAttributesDataProvider()
321
336
'frontend_label ' => 'fpt_label_frontend ' ,
322
337
'attribute_code ' => 'fpt_code ' ,
323
338
],
324
- 'expectedFptLabel ' => 'fpt_label_frontend '
325
- ]
339
+ 'websitePassed ' => 1 ,
340
+ 'expectedFptLabel ' => 'fpt_label_frontend ' ,
341
+ ],
342
+ 'website_not_passed ' => [
343
+ 'weeeTaxCalculationsByEntity ' => [
344
+ 'weee_value ' => 1 ,
345
+ 'label_value ' => '' ,
346
+ 'frontend_label ' => 'fpt_label_frontend ' ,
347
+ 'attribute_code ' => 'fpt_code ' ,
348
+ ],
349
+ 'websitePassed ' => null ,
350
+ 'expectedFptLabel ' => 'fpt_label_frontend ' ,
351
+ ],
326
352
];
327
353
}
328
354
0 commit comments