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 10.1 | AssertObjectProperty trait: polyfill the Assert::assertObject[Not]HasProperty() methods #116

Merged
merged 1 commit into from
Apr 16, 2023

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Apr 16, 2023

PHPUnit 10.1.0 introduces the new Assert::assertObjectHasProperty() and Assert::assertObjectNotHasProperty() 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 functional tests for the functionality polyfilled.

Includes:

  • Adding the new polyfill to the existing TestCases classes.

Refs:

…tObject[Not]HasProperty() methods

PHPUnit 10.1.0 introduces the new `Assert::assertObjectHasProperty()` and `Assert::assertObjectNotHasProperty()` 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 functional tests for the functionality polyfilled.

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

Refs:
* sebastianbergmann/phpunit#5220
* sebastianbergmann/phpunit#5231 (and follow up commits/PRs)

Co-authored-by: Jan-Sverre Riksfjord <[email protected]>
Co-authored-by: Sebastian Bergmann <[email protected]>
@jrfnl jrfnl added this to the 2.0.0 milestone Apr 16, 2023
@jrfnl jrfnl enabled auto-merge April 16, 2023 01:53
@jrfnl jrfnl merged commit 520d770 into 2.x Apr 16, 2023
@jrfnl jrfnl deleted the feature/phpunit-10.1-add-assertobjecthaspropertytrait branch April 16, 2023 01:54
@jrfnl jrfnl mentioned this pull request Apr 16, 2023
11 tasks
@@ -417,6 +417,18 @@ This method was introduced in PHPUnit 10.0.0.

[`Assert::assertIsList()`]: https://docs.phpunit.de/en/main/assertions.html#assertislist

#### PHPUnit < 10.1.0: `Yoast\PHPUnitPolyfills\Polyfills\AssertIsList`
Copy link

Choose a reason for hiding this comment

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

Wrong trait name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ow! Thanks for catching that @garak !

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(and yes, I have fixed it locally and that commit will be included in the 2.0.0 release.)

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.

2 participants