Skip to content

Commit 3eb0183

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1233 from magento-tango/MAGETWO-69859
[Tango] Bugfixes delivery
2 parents d902e08 + 72fb58e commit 3eb0183

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ protected function isValidOptionPrice($priceType, $price, $storeId)
8080
if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $priceType === null && $price === null) {
8181
return true;
8282
}
83+
if (!$priceType && !$price) {
84+
return true;
85+
}
8386
if (!$this->isInRange($priceType, $this->priceTypes) || $this->isNegative($price)) {
8487
return false;
8588
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,45 @@ protected function setUp()
5454
}
5555

5656
/**
57+
* @param bool $expectedResult
5758
* @param array $value
5859
* @dataProvider isValidSuccessDataProvider
5960
*/
60-
public function testIsValidSuccess($value)
61+
public function testIsValidSuccess($expectedResult, array $value)
6162
{
62-
$value = [
63-
'price_type' => 'fixed',
64-
'price' => '10',
65-
'title' => 'Some Title',
66-
];
6763
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
6864
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
6965
$this->valueMock->expects($this->never())->method('getPriceType');
7066
$this->valueMock->expects($this->never())->method('getPrice');
7167
$this->valueMock->expects($this->any())->method('getData')->with('values')->will($this->returnValue([$value]));
72-
$this->assertTrue($this->validator->isValid($this->valueMock));
73-
$this->assertEmpty($this->validator->getMessages());
68+
$this->assertEquals($expectedResult, $this->validator->isValid($this->valueMock));
7469
}
7570

7671
public function isValidSuccessDataProvider()
7772
{
78-
$value = [
79-
'price_type' => 'fixed',
80-
'price' => '10',
81-
'title' => 'Some Title',
82-
];
83-
84-
$valueWithoutAllData = [
85-
'some_data' => 'data',
86-
];
87-
8873
return [
89-
'all_data' => [$value],
90-
'not_all_data' => [$valueWithoutAllData]
74+
[
75+
true,
76+
[
77+
'price_type' => 'fixed',
78+
'price' => '10',
79+
'title' => 'Some Title',
80+
]
81+
],
82+
[
83+
true,
84+
[
85+
'title' => 'Some Title',
86+
]
87+
],
88+
[
89+
false,
90+
[
91+
'title' => 'Some Title',
92+
'price_type' => 'fixed',
93+
'price' => -10,
94+
]
95+
],
9196
];
9297
}
9398

0 commit comments

Comments
 (0)