Open ghost opened 1 year ago
Hi @francisco-serfe. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue: @magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @francisco-serfe , Thank you for reporting and collaboration. "sebastian/comparator" is a 3rd party package / library that doesn't come along with latest / default Magento installation. Code of this package is not part of https://github.com/magento/magento2 git repository. We are closing this issue as community is not able to provide fix for it in this repository. All questions, issue reports and fix for them should be addressed to the corresponding extension owners(support) or the Magento Market place page Thank you.
@engcom-November, what do you mean it doesn't come with a Magento installation? Yes it does, see here...
@francisco-serfe: does it still trigger even if you update phpunit to the latest compatible version?
I didn't pursue the issue since they'd eventually run into it anyways when they updated PHPUnit --with-dependencies
.
9.5.20
currently, with a ~9.5.20
constraint. phpunit
9.5.24
, "sebastian/comparator": "^4.0.5",
phpunit
9.5.25
, "sebastian/comparator": "^4.0.8",
I just ended up fixing our phpunit
version to 9.5.24
& sebastian/comparator
to 4.0.7
and don't plan on updating it until these tests are updated.
Well, reason I'm asking is because I think this was fixed in phpunit 9.5.25, when you can confirm, we don't need to reopen this issue 🙂
Hmm, nope, no dice.
phpunit/phpunit
: 9.5.25
sebastian/comparator
: 4.0.8
...
Magento\SalesRule\Test\Unit\Model\Rule\Action\Discount\ToPercentTest::testCalculate with data set #0 (3, array(30, 5), array(10, 50, 55), array(50, 45, 60, 55), 100, array(98, 59.5, 119, 80.5))
Expectation failed for method name is "setBaseAmount" when invoked 1 time(s)
Parameter 0 for invocation Magento\SalesRule\Model\Rule\Action\Discount\Data::setBaseAmount(59.49999999999999) does not match expected value.
Failed asserting that 59.49999999999999 matches expected 59.5.
vendor/magento/module-sales-rule/Model/Rule/Action/Discount/ByPercent.php:58
vendor/magento/module-sales-rule/Model/Rule/Action/Discount/ToPercent.php:19
vendor/magento/module-sales-rule/Test/Unit/Model/Rule/Action/Discount/ToPercentTest.php:204
...
Okay, thanks for confirming!
@engcom-November, @sdzhepa: I believe this issue needs to be reopened...
Also should mention I've experienced this on CE 2.4.4-p1
as well.
Hello,
We are reopening this issue to process it further.
Thanks
Verified the behavior on Magento 2.4-develop local instance and unit tests are getting failed with below steps performed: On running unit tests of mentioned modules from CLI, below errors are observed. Hence confirming the issue. ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Magento/SalesRule/Test/Unit ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Magento/Tax/Test/Unit
Note: There is no issue with MFTF test cases. Mentioned groups (sales, salesRule, tax) running fine in local instance. On running the command: vendor/bin/mftf run:group sales salesRule tax -r , MFTF tests are running fine.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-7097 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
I don't know Magento or what your test are actually doing, but I ran into this same issue after upgrading the library in my own Laravel repo, and then found this thread as the top search result. Here's what I found, in case it helps anyone else.
Old tests were passing but weren't actually correct before 4.0.8. You can see the behavior by writing this test:
public function testFloat()
{
// Passes with 4.0.6, fails with 4.0.8.
$this->assertEquals(0.21399575471878052, 0.21399575471878002);
}
Previously it was dropping off the last 3 values of precision, ending at 878
. Where the bug in our code seems to be is after we save this value to the database. If we set a model's property to the first value, it appears fine, but if we refresh the model from MySQL, that property ends up as the second value.
Our database column is defined as double(21, 20)
, and even so, it only seems to be accurate to 14 decimals.
Really, none of us should be comparing floats directly anyway (that's why bcmath and assertEqualsWithDelta()
exist), but we could get away with it due to a bug in versions before 4.0.8.
Do we have any workable for now?
It looks like some commits got added to 2.4-develop branch yesterday that will probably fix this, see: https://github.com/search?q=repo%3Amagento%2Fmagento2+float+comparison+precision&type=commits Unfortunately this wasn't done in a single merge commit, those got mixed up with a bunch of other things in https://github.com/magento/magento2/commit/ab0c0b54309d61d5bc207c73efad214e35516189
So I think this ticket can be closed? Maybe somebody first wants to confirm?
Preconditions and environment
Steps to reproduce
Run the MFTF unit tests over Sales, SalesRule and Tax modules.
Expected result
Tests pass.
Actual result
Additional information
See:
I'm guessing what should be done here is using assertEqualsWithDelta() instead.
Release note
No response
Triage and priority