Skip to content

Commit bf585a2

Browse files
Siarhei AndreyeuA-Komar
authored andcommitted
MAGNIMEX-6: Importing Advanced Prices
- fix tests.
1 parent a9c51df commit bf585a2

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator/TierPrice.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function isValid($value)
7878
) {
7979
$this->_addMessages([self::ERROR_INVALID_TIER_PRICE_GROUP]);
8080
return false;
81-
} elseif ($value[AdvancedPricing::COL_TIER_PRICE_QTY] <= 0 || $value[AdvancedPricing::COL_TIER_PRICE] <= 0) {
81+
} elseif ($value[AdvancedPricing::COL_TIER_PRICE_QTY] <= 0
82+
|| $value[AdvancedPricing::COL_TIER_PRICE] <= 0) {
8283
$this->_addMessages([self::ERROR_INVALID_TIER_PRICE_QTY]);
8384
return false;
8485
}

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator/Website.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ class Website extends AbstractValidator implements RowValidatorInterface
1818
protected $storeResolver;
1919

2020
/**
21-
* @var \Magento\Store\Model\WebSite
21+
* @var \Magento\Store\Model\Website
2222
*/
23-
protected $webSiteModel;
23+
protected $websiteModel;
2424

2525
/**
2626
* @param \Magento\CatalogImportExport\Model\Import\Product\StoreResolver $storeResolver
27-
* @param \Magento\Store\Model\WebSite $webSiteModel
27+
* @param \Magento\Store\Model\Website $websiteModel
2828
*/
2929
public function __construct(
3030
\Magento\CatalogImportExport\Model\Import\Product\StoreResolver $storeResolver,
31-
\Magento\Store\Model\WebSite $webSiteModel
31+
\Magento\Store\Model\Website $websiteModel
3232
) {
3333
$this->storeResolver = $storeResolver;
34-
$this->webSiteModel = $webSiteModel;
34+
$this->websiteModel = $websiteModel;
3535
}
3636

3737
/**
@@ -74,6 +74,6 @@ public function isValid($value)
7474
*/
7575
public function getAllWebsitesValue()
7676
{
77-
return AdvancedPricing::VALUE_ALL_WEBSITES . ' ['.$this->webSiteModel->getBaseCurrency()->getCurrencyCode().']';
77+
return AdvancedPricing::VALUE_ALL_WEBSITES . ' ['.$this->websiteModel->getBaseCurrency()->getCurrencyCode().']';
7878
}
7979
}

app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
*/
66
namespace Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin;
77

8+
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing;
9+
810
class Import extends \Magento\Catalog\Model\Indexer\Product\Price\Plugin\AbstractPlugin
911
{
1012
/**
1113
* After import handler
1214
*
15+
* @param AdvancedPricing $subject
1316
* @return void
17+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
1418
*/
15-
public function afterSaveAdvancedPricing()
19+
public function afterSaveAdvancedPricing(AdvancedPricing $subject)
1620
{
1721
if (!$this->getPriceIndexer()->isScheduled()) {
1822
$this->invalidateIndexer();
@@ -22,9 +26,11 @@ public function afterSaveAdvancedPricing()
2226
/**
2327
* After delete handler
2428
*
29+
* @param AdvancedPricing $subject
2530
* @return void
31+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2632
*/
27-
public function afterDeleteAdvancedPricing()
33+
public function afterDeleteAdvancedPricing(AdvancedPricing $subject)
2834
{
2935
if (!$this->getPriceIndexer()->isScheduled()) {
3036
$this->invalidateIndexer();

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class ImportTest extends \PHPUnit_Framework_TestCase
2020
*/
2121
protected $import;
2222

23+
/**
24+
* @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $advancedPricing;
27+
2328
public function setUp()
2429
{
2530
$this->indexer = $this->getMockForAbstractClass('\Magento\Indexer\Model\IndexerInterface', [], '', false);
@@ -30,6 +35,13 @@ public function setUp()
3035
'',
3136
false
3237
);
38+
$this->advancedPricing = $this->getMock(
39+
'\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing',
40+
[],
41+
[],
42+
'',
43+
false
44+
);
3345
$this->import->expects($this->any())->method('getPriceIndexer')->willReturn($this->indexer);
3446
}
3547

@@ -38,14 +50,14 @@ public function testAfterSaveAdvancedPricing()
3850
$this->indexer->expects($this->once())->method('isScheduled')->willReturn(false);
3951
$this->import->expects($this->once())->method('invalidateIndexer');
4052

41-
$this->import->afterSaveAdvancedPricing();
53+
$this->import->afterSaveAdvancedPricing($this->advancedPricing);
4254
}
4355

4456
public function testAfterDeleteAdvancedPricing()
4557
{
4658
$this->indexer->expects($this->once())->method('isScheduled')->willReturn(false);
4759
$this->import->expects($this->once())->method('invalidateIndexer');
4860

49-
$this->import->afterSaveAdvancedPricing();
61+
$this->import->afterSaveAdvancedPricing($this->advancedPricing);
5062
}
5163
}

app/code/Magento/AdvancedPricingImportExport/composer.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
"description": "N/A",
44
"require": {
55
"php": "~5.5.0|~5.6.0",
6-
"magento/module-catalog": "0.74.0-beta10",
7-
"magento/module-import-export": "0.74.0-beta10",
8-
"magento/indexer": "0.74.0-beta10",
9-
"magento/module-catalog-import-export": "0.74.0-beta10",
10-
"magento/module-customer": "0.74.0-beta10",
11-
"magento/module-eav": "0.74.0-beta10",
12-
"magento/module-store": "0.74.0-beta10",
13-
"magento/framework": "0.74.0-beta10",
6+
"magento/module-catalog": "0.74.0-beta12",
7+
"magento/module-import-export": "0.74.0-beta12",
8+
"magento/module-catalog-import-export": "0.74.0-beta12",
9+
"magento/module-customer": "0.74.0-beta12",
10+
"magento/module-store": "0.74.0-beta12",
11+
"magento/framework": "0.74.0-beta12",
1412
"magento/magento-composer-installer": "*"
1513
},
1614
"type": "magento2-module",
17-
"version": "0.74.0-beta10",
15+
"version": "0.74.0-beta12",
1816
"license": [
1917
"OSL-3.0",
2018
"AFL-3.0"

app/code/Magento/ImportExport/Test/Unit/Block/Adminhtml/Export/FilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @SuppressWarnings(PHPMD)
1212
*/
13-
class Filter extends \PHPUnit_Framework_TestCase
13+
class FilterTest extends \PHPUnit_Framework_TestCase
1414
{
1515
/**
1616
* @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject

0 commit comments

Comments
 (0)