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 | AssertArrayWithListKeys trait: polyfill the Assert::assertArrayIsEqualToArrayOnlyConsideringListOfKeys() et al methods #198

Merged

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Sep 6, 2024

PHPUnit 11.0.0 introduces the new Assert::assertArrayIsEqualToArrayOnlyConsideringListOfKeys(), Assert::assertArrayIsEqualToArrayIgnoringListOfKeys(), Assert::assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys() and Assert::assertArrayIsIdenticalToArrayIgnoringListOfKeys() methods.

This commit:

  • Adds two traits with the same name. One to polyfill the methods when not available in PHPUnit. The other - an empty trait - to allow for use-ing the trait in PHPUnit versions in which the methods are already natively available.
  • Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
  • An availability test and limited functional tests for the functionality polyfilled.

Includes:

  • Adding the new polyfill to the existing TestCases classes.

Refs:

…rtArrayIsEqualToArrayOnlyConsideringListOfKeys() et al methods

PHPUnit 11.0.0 introduces the new `Assert::assertArrayIsEqualToArrayOnlyConsideringListOfKeys()`, `Assert::assertArrayIsEqualToArrayIgnoringListOfKeys()`, `Assert::assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys()` and `Assert::assertArrayIsIdenticalToArrayIgnoringListOfKeys()` methods.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* An availability test and limited functional tests for the functionality polyfilled.

Includes:
* Adding the new polyfill to the existing `TestCases` classes.

Refs:
* sebastianbergmann/phpunit 5600
* sebastianbergmann/phpunit 5716
* sebastianbergmann/phpunit 5729

Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
@coveralls
Copy link

Coverage Status

coverage: 97.276% (+0.1%) from 97.152%
when pulling 3189123 on feature/3.x/new-assertarraywithlistkeys-polyfill-trait
into 5aa0561 on 3.x.

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 9ffaffb into 3.x Sep 6, 2024
160 checks passed
@hellofromtonya hellofromtonya deleted the feature/3.x/new-assertarraywithlistkeys-polyfill-trait branch September 6, 2024 20:42
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