-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Allow negative price for custom option: fixes #7333 in GitHub (internal MAGETWO-60573) #13393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
4d9c75e
0570a7c
df6e275
a846858
a553cd0
b11965f
b51d8c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ public function testIsValidTitle($title, $type, $priceType, $price, $product, $m | |
$valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title)); | ||
$valueMock->expects($this->any())->method('getType')->will($this->returnValue($type)); | ||
$valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType)); | ||
$valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price)); | ||
$valueMock->expects($this->never())->method('getPrice')->will($this->returnValue($price)); | ||
$valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product)); | ||
$this->assertEquals($result, $this->validator->isValid($valueMock)); | ||
$this->assertEquals($messages, $this->validator->getMessages()); | ||
|
@@ -129,7 +129,7 @@ public function testIsValidFail($product) | |
* Data provider for testValidationNegativePrice | ||
* @return array | ||
*/ | ||
public function validationNegativePriceDataProvider() | ||
public function negativePriceIsValidDataProvider() | ||
{ | ||
return [ | ||
['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\DataObject(['store_id' => 1])], | ||
|
@@ -143,22 +143,22 @@ public function validationNegativePriceDataProvider() | |
* @param $priceType | ||
* @param $price | ||
* @param $product | ||
* @dataProvider validationNegativePriceDataProvider | ||
* @dataProvider negativePriceIsValidDataProvider | ||
*/ | ||
public function testValidationNegativePrice($title, $type, $priceType, $price, $product) | ||
public function testNegativePriceIsValid($title, $type, $priceType, $price, $product) | ||
{ | ||
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; | ||
$valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods); | ||
$valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title)); | ||
$valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue($type)); | ||
$valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType)); | ||
$valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price)); | ||
$valueMock->expects($this->never())->method('getPrice')->will($this->returnValue($price)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same here. |
||
$valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product)); | ||
|
||
$messages = [ | ||
'option values' => 'Invalid option value', | ||
]; | ||
$this->assertFalse($this->validator->isValid($valueMock)); | ||
$this->assertEquals($messages, $this->validator->getMessages()); | ||
$this->assertTrue($this->validator->isValid($valueMock)); | ||
$this->assertNotEquals($messages, $this->validator->getMessages()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose making the check more specific, i.e., to check for the expected messages instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much for your feedback! Will make the proposed changes and improve the tests. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the method should never be called, the
will
is not necessary (and will probably confuse the reader).