Skip to content

MFTF-33780: Changed loose comparisons into strict #871

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

Merged
merged 2 commits into from
Sep 3, 2021
Merged

MFTF-33780: Changed loose comparisons into strict #871

merged 2 commits into from
Sep 3, 2021

Conversation

bohdan-harniuk
Copy link
Contributor

@bohdan-harniuk bohdan-harniuk commented Aug 19, 2021

Description

In this PR loose comparison operators were changed to the strict comparison operators.
These changes apply to the next comparison operators:

  1. == changed to ===
  2. != changed to !==

Reason of those changes:
With the PHP RFC updates often changes rules of loose comparison operators interpretation. So, for each MFTF codebase update to the new PHP version, if there is any update in the loose comparison operators interpretation, we must check every line of code where such operators are used to clarify if those changes applies to our codebase. A lot easier to replace loose operators with the strict ones to eliminate such problems in the future.

This PR doesn’t cover operations that perform non-strict comparisons with the next parts:

  • functions: in_array(), array_search() and array_keys() (without declaring strict types)
  • sorting functions: sort(), rsort(), asort(), arsort() and array_multisort() (with $sort_flags set to SORT_REGULAR, which is the default)

Those cases would be considered only if any build fails on them.

I've run all Magento 2 MFTF tests for the CE, EE, B2B repositories on the current branch:
Screenshot 2021-08-20 at 01 58 27
Screenshot 2021-08-20 at 01 57 36

All tests passed successfully:
Screenshot 2021-08-20 at 12 58 42

magento/magento2#33866

Fixed Issues (if relevant)

  1. [MFTF] Investigate and fix code affected by saner string to number comparisons magento2#33780: [MFTF] Investigate and fix code affected by saner string to number comparisons #33780

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

@magento-engcom-team magento-engcom-team added Partner: Atwix partners-contribution Pull Request is created by Magento Partner labels Aug 19, 2021
@bohdan-harniuk
Copy link
Contributor Author

Hello, @jilu1!

Please, proceed with the code review.

Thanks,
Bohdan.

@jilu1
Copy link
Contributor

jilu1 commented Aug 20, 2021

@bohdan-harniuk
The builds are run on PHP 7, right? Let's also run on PHP 8 when the docker image is available.

@jilu1
Copy link
Contributor

jilu1 commented Aug 20, 2021

@bohdan-harniuk
Copy link
Contributor Author

@bohdan-harniuk
The builds are run on PHP 7, right? Let's also run on PHP 8 when the docker image is available.

@jilu1
Yes, let’s do so!

Thanks,
Bohdan

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

@jilu1
Copy link
Contributor

jilu1 commented Aug 25, 2021

@bohdan-harniuk
I tried to merge this PR before PHP 8 is available, but when I run on PHP 7.4, I found these 4 tests consistently fail for EE and B2B builds. The failure is not present when running with MFTF develop branch. Can you please double check?
Screen Shot 2021-08-25 at 9 28 11 AM

@bohdan-harniuk
Copy link
Contributor Author

bohdan-harniuk commented Aug 30, 2021

@bohdan-harniuk
I tried to merge this PR before PHP 8 is available, but when I run on PHP 7.4, I found these 4 tests consistently fail for EE and B2B builds. The failure is not present when running with MFTF develop branch. Can you please double check?
Screen Shot 2021-08-25 at 9 28 11 AM

Hello, @jilu1!

You just need to rerun MFTF tests. There are few common issues with them. We see them quite often.
Sorry for being late. I missed the letter about it in gmail.

Thanks, Bohdan

@andrewbess
Copy link
Contributor

Hello @jilu1
FYI, currently, free API of currency converter is down
currency-converter-free-api-is-down
It will provoke an error in each functional test build

@jilu1
Copy link
Contributor

jilu1 commented Aug 30, 2021

@andrewbess @bohdan-harniuk
I have re-run builds later to decide if we can merge this PR now or wait for validation with PHP 8.

@bohdan-harniuk
Copy link
Contributor Author

Hello, @jilu1!

For now free API of currency converter is up:
Screenshot 2021-09-03 at 10 09 16

Could you please rerun builds from your side? You can additionally recheck if it is UP by this link: server-status

Thanks, Bohdan

Copy link
Contributor

@jilu1 jilu1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bohdan-harniuk
I checked the failing tests seem to be flaky. We will merge this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: Atwix partners-contribution Pull Request is created by Magento Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants