5
5
*/
6
6
namespace Magento \AdvancedPricingImportExport \Test \Unit \Model \Export ;
7
7
8
- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
9
8
use \Magento \Store \Model \Store ;
10
9
11
10
/**
@@ -98,8 +97,14 @@ class ExportTest extends \PHPUnit_Framework_TestCase
98
97
*/
99
98
protected $ rowCustomizer ;
100
99
100
+ /**
101
+ * @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver|\PHPUnit_Framework_MockObject_MockObject
102
+ */
101
103
protected $ storeResolver ;
102
104
105
+ /**
106
+ * @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
107
+ */
103
108
protected $ groupRepository ;
104
109
105
110
/**
@@ -112,14 +117,14 @@ class ExportTest extends \PHPUnit_Framework_TestCase
112
117
*/
113
118
protected $ advancedPricing ;
114
119
115
- protected $ _entityTypeCode ;
116
-
117
-
118
120
/**
119
121
* @var StubProduct|\Magento\CatalogImportExport\Model\Export\Product
120
122
*/
121
123
protected $ object ;
122
124
125
+ /**
126
+ * Set Up
127
+ */
123
128
protected function setUp ()
124
129
{
125
130
$ this ->localeDate = $ this ->getMock (
@@ -204,9 +209,12 @@ protected function setUp()
204
209
'' ,
205
210
false
206
211
);
207
- $ this ->_setColFactory = $ this ->getMock (
208
- '\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory ' ,
209
- ['create ' ],
212
+ $ this ->attrSetColFactory = $ this ->getMock (
213
+ 'Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory ' ,
214
+ [
215
+ 'create ' ,
216
+ 'setEntityTypeFilter ' ,
217
+ ],
210
218
[],
211
219
'' ,
212
220
false
@@ -327,7 +335,7 @@ protected function setUp()
327
335
$ this ->collection ,
328
336
$ this ->exportConfig ,
329
337
$ this ->productFactory ,
330
- $ this ->_setColFactory ,
338
+ $ this ->attrSetColFactory ,
331
339
$ this ->categoryColFactory ,
332
340
$ this ->itemFactory ,
333
341
$ this ->optionColFactory ,
@@ -340,7 +348,10 @@ protected function setUp()
340
348
);
341
349
}
342
350
343
- public function testExportCountZeroBreakInternalCalls ()
351
+ /**
352
+ * Test export with zero condition
353
+ */
354
+ public function testExportZeroConditionCalls ()
344
355
{
345
356
$ page = 1 ;
346
357
$ itemsPerPage = 10 ;
@@ -364,7 +375,10 @@ public function testExportCountZeroBreakInternalCalls()
364
375
$ this ->advancedPricing ->export ();
365
376
}
366
377
367
- public function testExportCurPageEqualToLastBreakInternalCalls ()
378
+ /**
379
+ * Test export for current page
380
+ */
381
+ public function testExportCurrentPageCalls ()
368
382
{
369
383
$ curPage = $ lastPage = $ page = 1 ;
370
384
$ itemsPerPage = 10 ;
@@ -379,23 +393,25 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
379
393
$ this ->abstractCollection ->expects ($ this ->once ())->method ('getCurPage ' )->willReturn ($ curPage );
380
394
$ this ->abstractCollection ->expects ($ this ->once ())->method ('getLastPageNumber ' )->willReturn ($ lastPage );
381
395
$ headers = ['headers ' ];
382
- $ this ->advancedPricing ->expects ($ this ->once ())->method ('_getHeaderColumns ' )->willReturn ($ headers );
383
- $ this ->writer ->expects ($ this ->once ())->method ('setHeaderCols ' )->with ($ headers );
396
+ $ this ->advancedPricing ->expects ($ this ->any ())->method ('_getHeaderColumns ' )->willReturn ($ headers );
397
+ $ this ->writer ->expects ($ this ->any ())->method ('setHeaderCols ' )->with ($ headers );
398
+ $ webSite = 'All Websites [USD] ' ;
399
+ $ userGroup = 'General ' ;
400
+ $ this ->advancedPricing ->expects ($ this ->any ())->method ('_getWebsiteCode ' )->willReturn ($ webSite );
401
+ $ this ->advancedPricing ->expects ($ this ->any ())->method ('_getCustomerGroupById ' )->willReturn ($ userGroup );
384
402
$ data = [
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 ' ,
403
+ [
404
+ 'sku ' => 'simpletest ' ,
405
+ 'group_price_website ' => $ webSite ,
406
+ 'group_price_customer_group ' => $ userGroup ,
407
+ 'group_price ' => '100 ' ,
408
+ 'tier_price_website ' => $ webSite ,
409
+ 'tier_price_customer_group ' => $ userGroup ,
410
+ 'tier_price_qty ' => '2 ' ,
411
+ 'tier_price ' => '23 ' ,
412
+ ]
393
413
];
394
414
$ this ->advancedPricing ->expects ($ this ->once ())->method ('getExportData ' )->willReturn ($ data );
395
- $ webSite = 'All Websites [USD] ' ;
396
- $ userGroup = 'General ' ;
397
- $ this ->advancedPricing ->expects ($ this ->once ())->method ('_getWebsiteCode ' )->willReturn ($ webSite );
398
- $ this ->advancedPricing ->expects ($ this ->once ())->method ('_getCustomerGroupById ' )->willReturn ($ userGroup );
399
415
$ exportData = [
400
416
'sku ' => 'simpletest ' ,
401
417
'group_price_website ' => $ webSite ,
@@ -406,11 +422,18 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
406
422
'tier_price_qty ' => '2 ' ,
407
423
'tier_price ' => '23 ' ,
408
424
];
425
+ $ this ->advancedPricing
426
+ ->expects ($ this ->any ())
427
+ ->method ('correctExportData ' )
428
+ ->willReturn ($ exportData );
409
429
$ this ->writer ->expects ($ this ->once ())->method ('writeRow ' )->with ($ exportData );
410
430
$ this ->writer ->expects ($ this ->once ())->method ('getContents ' );
411
431
$ this ->advancedPricing ->export ();
412
432
}
413
433
434
+ /**
435
+ * tearDown
436
+ */
414
437
protected function tearDown ()
415
438
{
416
439
unset($ this ->object );
0 commit comments