Skip to content
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

PHPUnit 11.2.0 | AssertObjectNotEquals trait: polyfill the Assert::assertObjectNotEquals() method #199

Merged

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Sep 6, 2024

AssertObjectEquals: move comparator validation logic to ComparatorValidator helper class

... as the same logic is needed for the (upcoming) PHPUnit 11.2+ AssertObjectNotEquals trait.

PHPUnit 11.2.0 | AssertObjectNotEquals trait: polyfill the Assert::assertObjectNotEquals() method

PHPUnit 11.2.0 introduced the new Assert::assertObjectNotEquals() method.

This commit:

  • Adds two traits with the same name.
    One to polyfill the method when not available in PHPUnit.
    The other to allow for use-ing the trait in PHPUnit versions in which the method is already natively available.
  • Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
  • Adds tests.

As the polyfill contains logic to match the PHPUnit native implementation as closely as possible, while still being PHP and PHPUnit cross-version compatible, extensive unit tests have been added to ensure the behaviour of the polyfill matches that of the original function.

Includes:

  • Adding information on the new polyfill to the README.
  • Adding the new polyfill to the existing TestCases classes.
  • Updating the class docs for the InvalidComparisonMethodException and the ComparatorValidator classes.

Refs:

@jrfnl jrfnl added this to the 3.0.0 milestone Sep 6, 2024
@jrfnl jrfnl changed the title Feature/3.x/new assertobjectnotequals polyfill trait PHPUnit 11.2.0 | AssertObjectNotEquals trait: polyfill the Assert::assertObjectNotEquals() method Sep 6, 2024
@coveralls
Copy link

coveralls commented Sep 6, 2024

Coverage Status

coverage: 97.444% (+0.2%) from 97.276%
when pulling 35688cc on feature/3.x/new-assertobjectnotequals-polyfill-trait
into 9ffaffb on 3.x.

jrfnl and others added 2 commits September 6, 2024 22:56
…lidator` helper class

... as the same logic is needed for the (upcoming) PHPUnit 11.2+ `AssertObjectNotEquals` trait.
…sertObjectNotEquals() method

PHPUnit 11.2.0 introduced the new `Assert::assertObjectNotEquals()` method.

This commit:
* Adds two traits with the same name.
    One to polyfill the method when not available in PHPUnit.
    The other to allow for `use`-ing the trait in PHPUnit versions in which the method is already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* Adds tests.

As the polyfill contains logic to match the PHPUnit native implementation as closely as possible, while still being PHP and PHPUnit cross-version compatible, extensive unit tests have been added to ensure the behaviour of the polyfill matches that of the original function.

Includes:
* Adding information on the new polyfill to the README.
* Adding the new polyfill to the existing `TestCases` classes.
* Updating the class docs for the `InvalidComparisonMethodException` and the `ComparatorValidator` classes.

Refs:
* sebastianbergmann/phpunit#5811
* sebastianbergmann/phpunit@8e3b7c1

Co-authored-by: Sebastian Bergmann <[email protected]>
@jrfnl jrfnl force-pushed the feature/3.x/new-assertobjectnotequals-polyfill-trait branch from a3622b2 to 35688cc Compare September 6, 2024 20:57
Copy link
Collaborator

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@hellofromtonya hellofromtonya merged commit d6537e8 into 3.x Sep 6, 2024
160 checks passed
@hellofromtonya hellofromtonya deleted the feature/3.x/new-assertobjectnotequals-polyfill-trait branch September 6, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants