-
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
Conversation
|
Just signed the CLA (and added the mail address to my github account as well) |
@@ -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)); |
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).
{ | ||
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
The same here.
$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 comment
The 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 comment
The 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.
…nvalid price types fail. Also makes sure price is not relevant for validation (assert that getPrice is not called)
Updated tests, to reflect the new situation:
|
Hi @luckyduck could you take a look at the merge conflict for me please, then I can process this PR. |
Oh, of course. Can you give me a hint, how best to do this? |
I would recommend updating your main First you need to add a new remote.
Then when you are checked out on your feature branch you can rebase on the upstream/2.2-develop branch rather than the origin/2.2-develop branch.
It will then ask you which commits you would like and it will also ask you to fix any conflicts that you come across. |
Hi @luckyduck thank you for this PR. I am currently doing a couple of things.
I will update you via this PR once I have some more information. Thank you for your patience. |
Hi @luckyduck thank you for your pull request. I am closing this pull request as it has been covered by #15267. |
Description
The price for custom options should be allowed to be negative. The contained changes do just that. In addition, a cosmetic problem is solved. Once options are allowed to be negative, available options (in a drop-down) add a plus sign as prefix to the price, resulting in '+-1,50 €" for a negative option price (-1,50 in this example). This is fixed as well.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist