-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-…
…59215
- Loading branch information
Showing
873 changed files
with
32,710 additions
and
7,532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator/TierPriceType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator; | ||
|
||
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing; | ||
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface; | ||
|
||
/** | ||
* Class TierPriceType validates tier price type. | ||
*/ | ||
class TierPriceType extends \Magento\CatalogImportExport\Model\Import\Product\Validator\AbstractImportValidator | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function init($context) | ||
{ | ||
return parent::init($context); | ||
} | ||
|
||
/** | ||
* Validate tier price type. | ||
* | ||
* @param array $value | ||
* @return bool | ||
*/ | ||
public function isValid($value) | ||
{ | ||
$isValid = true; | ||
|
||
if (isset($value[AdvancedPricing::COL_TIER_PRICE_TYPE]) | ||
&& !empty($value[AdvancedPricing::COL_TIER_PRICE_TYPE]) | ||
&& !in_array( | ||
$value[AdvancedPricing::COL_TIER_PRICE_TYPE], | ||
[AdvancedPricing::TIER_PRICE_TYPE_FIXED, AdvancedPricing::TIER_PRICE_TYPE_PERCENT] | ||
) | ||
) { | ||
$this->_addMessages([RowValidatorInterface::ERROR_INVALID_TIER_PRICE_TYPE]); | ||
$isValid = false; | ||
} | ||
|
||
return $isValid; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...ricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing\Validator; | ||
|
||
use \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing; | ||
|
||
/** | ||
* Class TierPriceTypeTest. | ||
*/ | ||
class TierPriceTypeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var AdvancedPricing\Validator\TierPriceType | ||
*/ | ||
private $tierPriceType; | ||
|
||
/** | ||
* Set up. | ||
* | ||
* @return void | ||
*/ | ||
protected function setUp() | ||
{ | ||
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->tierPriceType = $objectManager->getObject( | ||
AdvancedPricing\Validator\TierPriceType::class, | ||
[] | ||
); | ||
} | ||
|
||
/** | ||
* Test for isValid() method. | ||
* | ||
* @dataProvider isValidDataProvider | ||
* @param array $value | ||
* @param bool $expectedResult | ||
*/ | ||
public function testIsValid(array $value, $expectedResult) | ||
{ | ||
$result = $this->tierPriceType->isValid($value); | ||
$this->assertEquals($expectedResult, $result); | ||
} | ||
|
||
/** | ||
* Data Provider for testIsValid(). | ||
* | ||
* @return array | ||
*/ | ||
public function isValidDataProvider() | ||
{ | ||
return [ | ||
[ | ||
[AdvancedPricing::COL_TIER_PRICE_TYPE => AdvancedPricing::TIER_PRICE_TYPE_FIXED], | ||
true | ||
], | ||
[ | ||
[AdvancedPricing::COL_TIER_PRICE_TYPE => AdvancedPricing::TIER_PRICE_TYPE_PERCENT], | ||
true | ||
], | ||
[ | ||
[], | ||
true | ||
], | ||
[ | ||
[AdvancedPricing::COL_TIER_PRICE_TYPE => null], | ||
true | ||
], | ||
[ | ||
[AdvancedPricing::COL_TIER_PRICE_TYPE => 'wrong type'], | ||
false | ||
] | ||
]; | ||
} | ||
} |
Oops, something went wrong.