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 deprecations #60

Closed
Jean85 opened this issue Feb 6, 2024 · 5 comments
Closed

PHPUnit 11 deprecations #60

Jean85 opened this issue Feb 6, 2024 · 5 comments

Comments

@Jean85
Copy link
Contributor

Jean85 commented Feb 6, 2024

I've already opened #59 + phpspec/prophecy#616 to allow PHPUnit 11 compatibility, but I've already found that the ProphecyTrait triggers deprecations in that case. It triggers 2 deprecations for each test execution, so that A LOT of noise, especially if data providers are involved.

As already (wrongly) reported in sebastianbergmann/phpunit#5693 (comment),

[...] the causes are the @postCondition and @after annotations here:

Those annotations can be replaced by attributes since PHPUnit 10.0.0, or you can replace it with using the assertPostCondition and tearDown methods.

So, I'm asking, how should we proceed? I see 3 possibilities:

  • we switch to the assertPostCondition and tearDown methods, so that we don't drop support for older versions (but we mess with the inheritance chain of those methods, and the user could inadvertently deactivate that code path)
  • we switch to attributes, dropping support for PHPUnit 9
  • we do a mix, adding the methods but invoking the sub-methods only for PHPUnit 9, leaving the rest to the attributes

WDYT? ping @stof

@stof
Copy link
Member

stof commented Feb 6, 2024

We should not use assertPostCondition and tearDown because that would mean that any TestCase using the trait would then have to be careful to call our method when they use those extension points. That's precisely why PHPUnit added the feature to allow using arbitrary methods.

@sebastianbergmann would it work to apply both the attribute and the phpdoc tag as a way to support PHPUnit 9 and 11 at the same time, or would this register the methods twice for PHPUnit 10+ ?

@Jean85
Copy link
Contributor Author

Jean85 commented Feb 6, 2024

IMO using both would could trigger the deprecations anyway, so it would not solve our issue...

@stof
Copy link
Member

stof commented Feb 6, 2024

Well, that's what I'd like to confirm. It would be great if PHPUnit could support the case of applying both as a way to support multiple versions (basically ignoring the phpdoc tag if the attribute is applied).

@stof
Copy link
Member

stof commented Feb 6, 2024

@Jean85 Sebastian answered on the PHPUnit ticket. Defining both the attribute and the annotation on the method is the way to go to support multiple versions. PHPUnit 10+ ignores the annotation entirely when the attribute is present.

@stof
Copy link
Member

stof commented Feb 6, 2024

I'm closing this issue as the solution for those deprecations is found. Please update #59 to add the attribute without removing the annotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants