Skip to content

Add assertObjectHasProperty() and assertObjectNotHasProperty() to PHPUnit 9.6 #5478

@sebastianbergmann

Description

@sebastianbergmann

The assertions assertObjectHasAttribute() and assertObjectNotHasAttribute() were removed in PHPUnit 10.0. When this decision was made and the change implemented, there was no replacement planned for these methods.

PHPUnit 9.6 was released alongside PHPUnit 10.0 to warn about functionality that was removed in PHPUnit 10.0. This is why PHPUnit 9.6.0 deprecated assertObjectHasAttribute() and assertObjectNotHasAttribute() without suggesting an alternative.

The functionality was reintroduced, using new methods names assertObjectHasProperty() and assertObjectNotHasProperty(), in PHPUnit 10.1 because users convinced me that it is useful (I never had to use it myself). As of PHPUnit 9.6.7, the deprecations suggest to use these new methods.

This series of events lead to a mess that was discussed in #5448 as well as here and here, for instance.

To fix this mess, I will add assertObjectHasProperty() and assertObjectNotHasProperty() to PHPUnit 9.6.

Metadata

Metadata

Labels

feature/assertionIssues related to assertions and expectationstype/backward-compatibilitySomething will be/is intentionally brokenversion/9Something affects PHPUnit 9

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions