@@ -129,7 +129,6 @@ protected function setUp()
129
129
'' ,
130
130
false
131
131
);
132
-
133
132
$ this ->config = $ this ->getMock (
134
133
'Magento\Eav\Model\Config ' ,
135
134
['getEntityType ' ],
@@ -145,15 +144,13 @@ protected function setUp()
145
144
false
146
145
);
147
146
$ this ->config ->expects ($ this ->once ())->method ('getEntityType ' )->willReturn ($ type );
148
-
149
147
$ this ->resource = $ this ->getMock (
150
148
'Magento\Framework\App\Resource ' ,
151
149
[],
152
150
[],
153
151
'' ,
154
152
false
155
153
);
156
-
157
154
$ this ->storeManager = $ this ->getMock (
158
155
'Magento\Store\Model\StoreManager ' ,
159
156
[],
@@ -168,7 +165,6 @@ protected function setUp()
168
165
'' ,
169
166
false
170
167
);
171
-
172
168
$ this ->collection = $ this ->getMock (
173
169
'\Magento\Catalog\Model\Resource\Product\CollectionFactory ' ,
174
170
[],
@@ -198,7 +194,6 @@ protected function setUp()
198
194
'' ,
199
195
false
200
196
);
201
-
202
197
$ this ->productFactory = $ this ->getMock (
203
198
'Magento\Catalog\Model\Resource\ProductFactory ' ,
204
199
[
@@ -209,18 +204,13 @@ protected function setUp()
209
204
'' ,
210
205
false
211
206
);
212
-
213
- $ this ->attrSetColFactory = $ this ->getMock (
214
- 'Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory ' ,
215
- [
216
- 'create ' ,
217
- 'setEntityTypeFilter ' ,
218
- ],
207
+ $ this ->_setColFactory = $ this ->getMock (
208
+ '\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory ' ,
209
+ ['create ' ],
219
210
[],
220
211
'' ,
221
212
false
222
213
);
223
-
224
214
$ this ->categoryColFactory = $ this ->getMock (
225
215
'Magento\Catalog\Model\Resource\Category\CollectionFactory ' ,
226
216
[
@@ -231,7 +221,6 @@ protected function setUp()
231
221
'' ,
232
222
false
233
223
);
234
-
235
224
$ this ->itemFactory = $ this ->getMock (
236
225
'Magento\CatalogInventory\Model\Resource\Stock\ItemFactory ' ,
237
226
[],
@@ -246,7 +235,6 @@ protected function setUp()
246
235
'' ,
247
236
false
248
237
);
249
-
250
238
$ this ->attributeColFactory = $ this ->getMock (
251
239
'Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory ' ,
252
240
[],
@@ -261,7 +249,6 @@ protected function setUp()
261
249
'' ,
262
250
false
263
251
);
264
-
265
252
$ this ->linkTypeProvider = $ this ->getMock (
266
253
'Magento\Catalog\Model\Product\LinkTypeProvider ' ,
267
254
[],
@@ -290,7 +277,6 @@ protected function setUp()
290
277
'' ,
291
278
false
292
279
);
293
-
294
280
$ this ->writer = $ this ->getMock (
295
281
'Magento\ImportExport\Model\Export\Adapter\AbstractAdapter ' ,
296
282
[
@@ -302,7 +288,6 @@ protected function setUp()
302
288
'' ,
303
289
false
304
290
);
305
-
306
291
$ constructorMethods = [
307
292
'initTypeModels ' ,
308
293
'initAttributes ' ,
@@ -311,7 +296,6 @@ protected function setUp()
311
296
'initWebsites ' ,
312
297
'initCategories '
313
298
];
314
-
315
299
$ mockMethods = array_merge ($ constructorMethods , [
316
300
'_customHeadersMapping ' ,
317
301
'_prepareEntityCollection ' ,
@@ -331,11 +315,9 @@ protected function setUp()
331
315
'' ,
332
316
false
333
317
);
334
-
335
318
foreach ($ constructorMethods as $ method ) {
336
319
$ this ->advancedPricing ->expects ($ this ->once ())->method ($ method )->will ($ this ->returnSelf ());
337
320
}
338
-
339
321
$ this ->advancedPricing ->__construct (
340
322
$ this ->localeDate ,
341
323
$ this ->config ,
@@ -345,7 +327,7 @@ protected function setUp()
345
327
$ this ->collection ,
346
328
$ this ->exportConfig ,
347
329
$ this ->productFactory ,
348
- $ this ->attrSetColFactory ,
330
+ $ this ->_setColFactory ,
349
331
$ this ->categoryColFactory ,
350
332
$ this ->itemFactory ,
351
333
$ this ->optionColFactory ,
@@ -370,71 +352,62 @@ public function testExportCountZeroBreakInternalCalls()
370
352
$ this ->advancedPricing ->expects ($ this ->once ())->method ('paginateCollection ' )->with ($ page , $ itemsPerPage );
371
353
$ this ->abstractCollection ->expects ($ this ->once ())->method ('setOrder ' )->with ('has_options ' , 'asc ' );
372
354
$ this ->abstractCollection ->expects ($ this ->once ())->method ('setStoreId ' )->with (Store::DEFAULT_STORE_ID );
373
-
374
355
$ this ->abstractCollection ->expects ($ this ->once ())->method ('count ' )->willReturn (0 );
375
-
376
356
$ this ->abstractCollection ->expects ($ this ->never ())->method ('getCurPage ' );
377
357
$ this ->abstractCollection ->expects ($ this ->never ())->method ('getLastPageNumber ' );
378
358
$ this ->advancedPricing ->expects ($ this ->never ())->method ('_getHeaderColumns ' );
379
359
$ this ->writer ->expects ($ this ->never ())->method ('setHeaderCols ' );
380
360
$ this ->writer ->expects ($ this ->never ())->method ('writeRow ' );
381
361
$ this ->advancedPricing ->expects ($ this ->never ())->method ('getExportData ' );
382
362
$ this ->advancedPricing ->expects ($ this ->never ())->method ('_customFieldsMapping ' );
383
-
384
363
$ this ->writer ->expects ($ this ->once ())->method ('getContents ' );
385
-
386
364
$ this ->advancedPricing ->export ();
387
365
}
388
366
389
367
public function testExportCurPageEqualToLastBreakInternalCalls ()
390
368
{
391
369
$ curPage = $ lastPage = $ page = 1 ;
392
370
$ itemsPerPage = 10 ;
393
-
394
371
$ this ->advancedPricing ->expects ($ this ->once ())->method ('getWriter ' )->willReturn ($ this ->writer );
395
372
$ this ->advancedPricing ->expects ($ this ->exactly (1 ))->method ('_getEntityCollection ' )->willReturn ($ this ->abstractCollection );
396
373
$ this ->advancedPricing ->expects ($ this ->once ())->method ('_prepareEntityCollection ' )->with ($ this ->abstractCollection );
397
374
$ this ->advancedPricing ->expects ($ this ->once ())->method ('getItemsPerPage ' )->willReturn ($ itemsPerPage );
398
375
$ this ->advancedPricing ->expects ($ this ->once ())->method ('paginateCollection ' )->with ($ page , $ itemsPerPage );
399
376
$ this ->abstractCollection ->expects ($ this ->once ())->method ('setOrder ' )->with ('has_options ' , 'asc ' );
400
377
$ this ->abstractCollection ->expects ($ this ->once ())->method ('setStoreId ' )->with (Store::DEFAULT_STORE_ID );
401
-
402
378
$ this ->abstractCollection ->expects ($ this ->once ())->method ('count ' )->willReturn (1 );
403
-
404
379
$ this ->abstractCollection ->expects ($ this ->once ())->method ('getCurPage ' )->willReturn ($ curPage );
405
380
$ this ->abstractCollection ->expects ($ this ->once ())->method ('getLastPageNumber ' )->willReturn ($ lastPage );
406
381
$ headers = ['headers ' ];
407
382
$ this ->advancedPricing ->expects ($ this ->once ())->method ('_getHeaderColumns ' )->willReturn ($ headers );
408
383
$ this ->writer ->expects ($ this ->once ())->method ('setHeaderCols ' )->with ($ headers );
409
384
$ data = [
410
- ImportAdvancedPricing:: COL_SKU => 'simpletest ' ,
411
- ImportAdvancedPricing:: COL_GROUP_PRICE_WEBSITE => '0 ' ,
412
- ImportAdvancedPricing:: COL_GROUP_PRICE_CUSTOMER_GROUP => '1 ' ,
413
- ImportAdvancedPricing:: COL_GROUP_PRICE => '100 ' ,
414
- ImportAdvancedPricing:: COL_TIER_PRICE_WEBSITE => '0 ' ,
415
- ImportAdvancedPricing:: COL_TIER_PRICE_CUSTOMER_GROUP => '2 ' ,
416
- ImportAdvancedPricing:: COL_TIER_PRICE_QTY => '2 ' ,
417
- ImportAdvancedPricing:: COL_TIER_PRICE => '23 ' ,
385
+ ' sku ' => 'simpletest ' ,
386
+ ' group_price_website ' => '0 ' ,
387
+ ' group_price_customer_group ' => '1 ' ,
388
+ ' group_price ' => '100 ' ,
389
+ ' tier_price_website ' => '0 ' ,
390
+ ' tier_price_customer_group ' => '2 ' ,
391
+ ' tier_price_qty ' => '2 ' ,
392
+ ' tier_price ' => '23 ' ,
418
393
];
419
394
$ this ->advancedPricing ->expects ($ this ->once ())->method ('getExportData ' )->willReturn ($ data );
420
395
$ webSite = 'All Websites [USD] ' ;
421
396
$ userGroup = 'General ' ;
422
397
$ this ->advancedPricing ->expects ($ this ->once ())->method ('_getWebsiteCode ' )->willReturn ($ webSite );
423
398
$ this ->advancedPricing ->expects ($ this ->once ())->method ('_getCustomerGroupById ' )->willReturn ($ userGroup );
424
399
$ exportData = [
425
- ImportAdvancedPricing:: COL_SKU => 'simpletest ' ,
426
- ImportAdvancedPricing:: COL_GROUP_PRICE_WEBSITE => $ webSite ,
427
- ImportAdvancedPricing:: COL_GROUP_PRICE_CUSTOMER_GROUP => $ userGroup ,
428
- ImportAdvancedPricing:: COL_GROUP_PRICE => '100 ' ,
429
- ImportAdvancedPricing:: COL_TIER_PRICE_WEBSITE => $ webSite ,
430
- ImportAdvancedPricing:: COL_TIER_PRICE_CUSTOMER_GROUP => $ userGroup ,
431
- ImportAdvancedPricing:: COL_TIER_PRICE_QTY => '2 ' ,
432
- ImportAdvancedPricing:: COL_TIER_PRICE => '23 ' ,
400
+ ' sku ' => 'simpletest ' ,
401
+ ' group_price_website ' => $ webSite ,
402
+ ' group_price_customer_group ' => $ userGroup ,
403
+ ' group_price ' => '100 ' ,
404
+ ' tier_price_website ' => $ webSite ,
405
+ ' tier_price_customer_group ' => $ userGroup ,
406
+ ' tier_price_qty ' => '2 ' ,
407
+ ' tier_price ' => '23 ' ,
433
408
];
434
409
$ this ->writer ->expects ($ this ->once ())->method ('writeRow ' )->with ($ exportData );
435
-
436
410
$ this ->writer ->expects ($ this ->once ())->method ('getContents ' );
437
-
438
411
$ this ->advancedPricing ->export ();
439
412
}
440
413
@@ -455,7 +428,6 @@ protected function getPropertyValue($object, $property)
455
428
$ reflection = new \ReflectionClass (get_class ($ object ));
456
429
$ reflectionProperty = $ reflection ->getProperty ($ property );
457
430
$ reflectionProperty ->setAccessible (true );
458
-
459
431
return $ reflectionProperty ->getValue ($ object );
460
432
}
461
433
@@ -472,7 +444,6 @@ protected function setPropertyValue(&$object, $property, $value)
472
444
$ reflectionProperty = $ reflection ->getProperty ($ property );
473
445
$ reflectionProperty ->setAccessible (true );
474
446
$ reflectionProperty ->setValue ($ object , $ value );
475
-
476
447
return $ object ;
477
448
}
478
449
}
0 commit comments