@@ -39,10 +39,15 @@ class ProductTest extends \PHPUnit_Framework_TestCase
39
39
protected $ logger ;
40
40
41
41
/**
42
- * @var \Magento\Catalog\Model\Resource\Product\Collection |\PHPUnit_Framework_MockObject_MockObject
42
+ * @var \Magento\Catalog\Model\Resource\Product\CollectionFactory |\PHPUnit_Framework_MockObject_MockObject
43
43
*/
44
44
protected $ collection ;
45
45
46
+ /**
47
+ * @var \Magento\Eav\Model\Entity\Collection\AbstractCollection|\PHPUnit_Framework_MockObject_MockObject
48
+ */
49
+ protected $ abstractCollection ;
50
+
46
51
/**
47
52
* @var \Magento\ImportExport\Model\Export\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
48
53
*/
@@ -159,17 +164,26 @@ protected function setUp()
159
164
);
160
165
161
166
$ this ->collection = $ this ->getMock (
162
- 'Magento\Catalog\Model\Resource\Product\Collection ' ,
167
+ '\Magento\Catalog\Model\Resource\Product\CollectionFactory ' ,
168
+ [],
169
+ [],
170
+ '' ,
171
+ false
172
+ );
173
+ $ this ->abstractCollection = $ this ->getMockForAbstractClass (
174
+ '\Magento\Eav\Model\Entity\Collection\AbstractCollection ' ,
175
+ [],
176
+ '' ,
177
+ false ,
178
+ true ,
179
+ true ,
163
180
[
164
181
'count ' ,
165
182
'setOrder ' ,
166
183
'setStoreId ' ,
167
184
'getCurPage ' ,
168
185
'getLastPageNumber ' ,
169
- ],
170
- [],
171
- '' ,
172
- false
186
+ ]
173
187
);
174
188
$ this ->exportConfig = $ this ->getMock (
175
189
'Magento\ImportExport\Model\Export\Config ' ,
@@ -370,17 +384,17 @@ public function testExportCountZeroBreakInternalCalls()
370
384
$ itemsPerPage = 10 ;
371
385
372
386
$ this ->product ->expects ($ this ->once ())->method ('getWriter ' )->willReturn ($ this ->writer );
373
- $ this ->product ->expects ($ this ->exactly (4 ))->method ('_getEntityCollection ' )->willReturn ($ this ->collection );
374
- $ this ->product ->expects ($ this ->once ())->method ('_prepareEntityCollection ' )->with ($ this ->collection );
387
+ $ this ->product ->expects ($ this ->exactly (1 ))->method ('_getEntityCollection ' )->willReturn ($ this ->abstractCollection );
388
+ $ this ->product ->expects ($ this ->once ())->method ('_prepareEntityCollection ' )->with ($ this ->abstractCollection );
375
389
$ this ->product ->expects ($ this ->once ())->method ('getItemsPerPage ' )->willReturn ($ itemsPerPage );
376
390
$ this ->product ->expects ($ this ->once ())->method ('paginateCollection ' )->with ($ page , $ itemsPerPage );
377
- $ this ->collection ->expects ($ this ->once ())->method ('setOrder ' )->with ('has_options ' , 'asc ' );
378
- $ this ->collection ->expects ($ this ->once ())->method ('setStoreId ' )->with (Store::DEFAULT_STORE_ID );
391
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('setOrder ' )->with ('has_options ' , 'asc ' );
392
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('setStoreId ' )->with (Store::DEFAULT_STORE_ID );
379
393
380
- $ this ->collection ->expects ($ this ->once ())->method ('count ' )->willReturn (0 );
394
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('count ' )->willReturn (0 );
381
395
382
- $ this ->collection ->expects ($ this ->never ())->method ('getCurPage ' );
383
- $ this ->collection ->expects ($ this ->never ())->method ('getLastPageNumber ' );
396
+ $ this ->abstractCollection ->expects ($ this ->never ())->method ('getCurPage ' );
397
+ $ this ->abstractCollection ->expects ($ this ->never ())->method ('getLastPageNumber ' );
384
398
$ this ->product ->expects ($ this ->never ())->method ('_getHeaderColumns ' );
385
399
$ this ->writer ->expects ($ this ->never ())->method ('setHeaderCols ' );
386
400
$ this ->writer ->expects ($ this ->never ())->method ('writeRow ' );
@@ -398,17 +412,17 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
398
412
$ itemsPerPage = 10 ;
399
413
400
414
$ this ->product ->expects ($ this ->once ())->method ('getWriter ' )->willReturn ($ this ->writer );
401
- $ this ->product ->expects ($ this ->exactly (6 ))->method ('_getEntityCollection ' )->willReturn ($ this ->collection );
402
- $ this ->product ->expects ($ this ->once ())->method ('_prepareEntityCollection ' )->with ($ this ->collection );
415
+ $ this ->product ->expects ($ this ->exactly (1 ))->method ('_getEntityCollection ' )->willReturn ($ this ->abstractCollection );
416
+ $ this ->product ->expects ($ this ->once ())->method ('_prepareEntityCollection ' )->with ($ this ->abstractCollection );
403
417
$ this ->product ->expects ($ this ->once ())->method ('getItemsPerPage ' )->willReturn ($ itemsPerPage );
404
418
$ this ->product ->expects ($ this ->once ())->method ('paginateCollection ' )->with ($ page , $ itemsPerPage );
405
- $ this ->collection ->expects ($ this ->once ())->method ('setOrder ' )->with ('has_options ' , 'asc ' );
406
- $ this ->collection ->expects ($ this ->once ())->method ('setStoreId ' )->with (Store::DEFAULT_STORE_ID );
419
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('setOrder ' )->with ('has_options ' , 'asc ' );
420
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('setStoreId ' )->with (Store::DEFAULT_STORE_ID );
407
421
408
- $ this ->collection ->expects ($ this ->once ())->method ('count ' )->willReturn (1 );
422
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('count ' )->willReturn (1 );
409
423
410
- $ this ->collection ->expects ($ this ->once ())->method ('getCurPage ' )->willReturn ($ curPage );
411
- $ this ->collection ->expects ($ this ->once ())->method ('getLastPageNumber ' )->willReturn ($ lastPage );
424
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('getCurPage ' )->willReturn ($ curPage );
425
+ $ this ->abstractCollection ->expects ($ this ->once ())->method ('getLastPageNumber ' )->willReturn ($ lastPage );
412
426
$ headers = ['headers ' ];
413
427
$ this ->product ->expects ($ this ->once ())->method ('_getHeaderColumns ' )->willReturn ($ headers );
414
428
$ this ->writer ->expects ($ this ->once ())->method ('setHeaderCols ' )->with ($ headers );
0 commit comments