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

Prepare tests for PHPUnit 10 #162

Merged

Conversation

aadmathijssen
Copy link
Contributor

@aadmathijssen aadmathijssen commented Jul 15, 2024

Prepare test classes for use with PHPUnit 10 while maintaining compatibility with older versions of PHPUnit:

  • Use onlyMethods instead of setMethods on MockBuilder instance when available, as setMethods has been removed in PHPUnit 10.
  • Avoid mandatory void return type of the inherited setUp method in PHPUnit 10.
  • Mark all data providers as static as non-static data providers are deprecated in PHPUnit 10 (this is already merged via Mark all data providers in test suite as static #163).

Note that the symfony/phpunit-bridge package does not support PHPunit 10. So in order to run the test suite with this version, the 10.x version of the tool should be installed as a PHAR or via Composer (composer require --dev phpunit/phpunit:~10.5).

@Seldaek Seldaek force-pushed the feature/prepare-tests-for-phpunit-10 branch from eb431f7 to 9040637 Compare August 21, 2024 16:03
@Seldaek
Copy link
Member

Seldaek commented Aug 21, 2024

Thanks but it breaks 5.3 though.. so I guess I'll keep this open for now but it'll not be mergeable until we drop old PHP versions.. Given how little this library change I am not really keen on doing this right now.

@aadmathijssen
Copy link
Contributor Author

Hi @Seldaek, thanks for fixing the test suite. I can now also see that this breaks PHP 5.3, which was never my intention!

I have cherry-picked the commit that marks all data providers as static to a new PR: #163.
That 's the only commit in this PR that does not have any downsides (and it's the one I actually need for my own project ☺️).

Can you please check that one?

I think I will close this PR as soon as the other PR is merged; that way, it's still documented how the test suite can be made compatible with PHPUnit 10.

Thanks!

Aad

@Seldaek
Copy link
Member

Seldaek commented Aug 21, 2024

Yup makes sense thanks for that. But I'd still keep this open as if it's closed it'll get lost imo.

… PHPUnit 10

This is done by renaming the inherited `setUp` method to a new `setUpTestCase` method and adding an `@before` annotation.
@aadmathijssen aadmathijssen force-pushed the feature/prepare-tests-for-phpunit-10 branch 2 times, most recently from 2a52e3c to 2ed85d9 Compare August 22, 2024 08:37
…n available

This resolves the following error when running the test suite using PHPUnit 10:

    Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::setMethods()
@aadmathijssen aadmathijssen force-pushed the feature/prepare-tests-for-phpunit-10 branch from 2ed85d9 to 3ad9b77 Compare August 22, 2024 09:20
@aadmathijssen
Copy link
Contributor Author

Hi @Seldaek,

I have managed to change the PR such that all changes still work with PHP 5.3 and PHPUnit 4.8.

Can you please check this PR again?

Thanks!

Aad

@Seldaek
Copy link
Member

Seldaek commented Aug 22, 2024

Thanks yes looks good.

@Seldaek Seldaek merged commit 4b9538f into composer:main Aug 22, 2024
15 checks passed
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

Successfully merging this pull request may close these issues.

2 participants