Skip to content

Commit ac09ec7

Browse files
Andrei KuprienkaA-Komar
authored andcommitted
MAGNIMEX-6: fixed unit tests
1 parent d2c3d5f commit ac09ec7

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public function validateRowAddRowErrorCallDataProvider()
595595
0 => ['value']
596596
],
597597
'$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE,
598-
'$error' => RowValidatorInterface::ERROR_SKU_NOT_FOUND_FOR_DELETE,
598+
'$error' => RowValidatorInterface::ERROR_SKU_IS_EMPTY,
599599
],
600600
[
601601
'$rowData' => [

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ class ProductTest extends \PHPUnit_Framework_TestCase
3939
protected $logger;
4040

4141
/**
42-
* @var \Magento\Catalog\Model\Resource\Product\Collection|\PHPUnit_Framework_MockObject_MockObject
42+
* @var \Magento\Catalog\Model\Resource\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
4343
*/
4444
protected $collection;
4545

46+
/**
47+
* @var \Magento\Eav\Model\Entity\Collection\AbstractCollection|\PHPUnit_Framework_MockObject_MockObject
48+
*/
49+
protected $abstractCollection;
50+
4651
/**
4752
* @var \Magento\ImportExport\Model\Export\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
4853
*/
@@ -159,17 +164,26 @@ protected function setUp()
159164
);
160165

161166
$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,
163180
[
164181
'count',
165182
'setOrder',
166183
'setStoreId',
167184
'getCurPage',
168185
'getLastPageNumber',
169-
],
170-
[],
171-
'',
172-
false
186+
]
173187
);
174188
$this->exportConfig = $this->getMock(
175189
'Magento\ImportExport\Model\Export\Config',
@@ -370,17 +384,17 @@ public function testExportCountZeroBreakInternalCalls()
370384
$itemsPerPage = 10;
371385

372386
$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);
375389
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
376390
$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);
379393

380-
$this->collection->expects($this->once())->method('count')->willReturn(0);
394+
$this->abstractCollection->expects($this->once())->method('count')->willReturn(0);
381395

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');
384398
$this->product->expects($this->never())->method('_getHeaderColumns');
385399
$this->writer->expects($this->never())->method('setHeaderCols');
386400
$this->writer->expects($this->never())->method('writeRow');
@@ -398,17 +412,17 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
398412
$itemsPerPage = 10;
399413

400414
$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);
403417
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
404418
$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);
407421

408-
$this->collection->expects($this->once())->method('count')->willReturn(1);
422+
$this->abstractCollection->expects($this->once())->method('count')->willReturn(1);
409423

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);
412426
$headers = ['headers'];
413427
$this->product->expects($this->once())->method('_getHeaderColumns')->willReturn($headers);
414428
$this->writer->expects($this->once())->method('setHeaderCols')->with($headers);

0 commit comments

Comments
 (0)