Skip to content

Commit

Permalink
Merge pull request #1233 from magento-tango/MAGETWO-69859
Browse files Browse the repository at this point in the history
[Tango] Bugfixes delivery
  • Loading branch information
Oleksii Korshenko authored Jun 29, 2017
2 parents d902e08 + 72fb58e commit 3eb0183
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ protected function isValidOptionPrice($priceType, $price, $storeId)
if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $priceType === null && $price === null) {
return true;
}
if (!$priceType && !$price) {
return true;
}
if (!$this->isInRange($priceType, $this->priceTypes) || $this->isNegative($price)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,45 @@ protected function setUp()
}

/**
* @param bool $expectedResult
* @param array $value
* @dataProvider isValidSuccessDataProvider
*/
public function testIsValidSuccess($value)
public function testIsValidSuccess($expectedResult, array $value)
{
$value = [
'price_type' => 'fixed',
'price' => '10',
'title' => 'Some Title',
];
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
$this->valueMock->expects($this->never())->method('getPriceType');
$this->valueMock->expects($this->never())->method('getPrice');
$this->valueMock->expects($this->any())->method('getData')->with('values')->will($this->returnValue([$value]));
$this->assertTrue($this->validator->isValid($this->valueMock));
$this->assertEmpty($this->validator->getMessages());
$this->assertEquals($expectedResult, $this->validator->isValid($this->valueMock));
}

public function isValidSuccessDataProvider()
{
$value = [
'price_type' => 'fixed',
'price' => '10',
'title' => 'Some Title',
];

$valueWithoutAllData = [
'some_data' => 'data',
];

return [
'all_data' => [$value],
'not_all_data' => [$valueWithoutAllData]
[
true,
[
'price_type' => 'fixed',
'price' => '10',
'title' => 'Some Title',
]
],
[
true,
[
'title' => 'Some Title',
]
],
[
false,
[
'title' => 'Some Title',
'price_type' => 'fixed',
'price' => -10,
]
],
];
}

Expand Down

0 comments on commit 3eb0183

Please sign in to comment.