Skip to content

Commit 37d919a

Browse files
Merge branch 'MAGNIMEX-156-units' into 'master'
Magnimex 156 units See merge request !174
2 parents 01c2298 + 1fd3613 commit 37d919a

File tree

1 file changed

+47
-24
lines changed

1 file changed

+47
-24
lines changed

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

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Export;
77

8-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
98
use \Magento\Store\Model\Store;
109

1110
/**
@@ -98,8 +97,14 @@ class ExportTest extends \PHPUnit_Framework_TestCase
9897
*/
9998
protected $rowCustomizer;
10099

100+
/**
101+
* @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver|\PHPUnit_Framework_MockObject_MockObject
102+
*/
101103
protected $storeResolver;
102104

105+
/**
106+
* @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
107+
*/
103108
protected $groupRepository;
104109

105110
/**
@@ -112,14 +117,14 @@ class ExportTest extends \PHPUnit_Framework_TestCase
112117
*/
113118
protected $advancedPricing;
114119

115-
protected $_entityTypeCode;
116-
117-
118120
/**
119121
* @var StubProduct|\Magento\CatalogImportExport\Model\Export\Product
120122
*/
121123
protected $object;
122124

125+
/**
126+
* Set Up
127+
*/
123128
protected function setUp()
124129
{
125130
$this->localeDate = $this->getMock(
@@ -204,9 +209,12 @@ protected function setUp()
204209
'',
205210
false
206211
);
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+
],
210218
[],
211219
'',
212220
false
@@ -327,7 +335,7 @@ protected function setUp()
327335
$this->collection,
328336
$this->exportConfig,
329337
$this->productFactory,
330-
$this->_setColFactory,
338+
$this->attrSetColFactory,
331339
$this->categoryColFactory,
332340
$this->itemFactory,
333341
$this->optionColFactory,
@@ -340,7 +348,10 @@ protected function setUp()
340348
);
341349
}
342350

343-
public function testExportCountZeroBreakInternalCalls()
351+
/**
352+
* Test export with zero condition
353+
*/
354+
public function testExportZeroConditionCalls()
344355
{
345356
$page = 1;
346357
$itemsPerPage = 10;
@@ -364,7 +375,10 @@ public function testExportCountZeroBreakInternalCalls()
364375
$this->advancedPricing->export();
365376
}
366377

367-
public function testExportCurPageEqualToLastBreakInternalCalls()
378+
/**
379+
* Test export for current page
380+
*/
381+
public function testExportCurrentPageCalls()
368382
{
369383
$curPage = $lastPage = $page = 1;
370384
$itemsPerPage = 10;
@@ -379,23 +393,25 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
379393
$this->abstractCollection->expects($this->once())->method('getCurPage')->willReturn($curPage);
380394
$this->abstractCollection->expects($this->once())->method('getLastPageNumber')->willReturn($lastPage);
381395
$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);
384402
$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+
]
393413
];
394414
$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);
399415
$exportData = [
400416
'sku' => 'simpletest',
401417
'group_price_website' => $webSite,
@@ -406,11 +422,18 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
406422
'tier_price_qty' => '2',
407423
'tier_price' => '23',
408424
];
425+
$this->advancedPricing
426+
->expects($this->any())
427+
->method('correctExportData')
428+
->willReturn($exportData);
409429
$this->writer->expects($this->once())->method('writeRow')->with($exportData);
410430
$this->writer->expects($this->once())->method('getContents');
411431
$this->advancedPricing->export();
412432
}
413433

434+
/**
435+
* tearDown
436+
*/
414437
protected function tearDown()
415438
{
416439
unset($this->object);

0 commit comments

Comments
 (0)