Skip to content

Support PHPUnit 12 by avoiding removed methods getMockForAbstractClass() and addMethods() #75

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

Merged
merged 8 commits into from
Mar 8, 2025

Conversation

crocodele
Copy link
Contributor

This is an attempt to address #71 and support PHPUnit 12 by removing the use of the PHPUnit methods getMockForAbstractClass() and addMethods() that were deprecated in PHPUnit 11 and removed without replacements in PHPUnit 12.

It relies on a change in php-mock-integration, making the mock class non-abstract and adding an actual function that can be mocked using onlyMethods(). See https://github.com/php-mock/php-mock-integration/compare/master...crocodele:feature/SupportPhpUnit12?expand=1.

I haven't looked into the effects on php-mock-mockery and php-mock-prophecy, but can return to that if the general approach seems OK.

@rvalitov
Copy link

rvalitov commented Mar 7, 2025

I guess the composer.json should also be changed to support PHPUnit 12 #76

@crocodele
Copy link
Contributor Author

Needs the changes in php-mock/php-mock-integration#13 for the tests.

@crocodele
Copy link
Contributor Author

OK, now the tests are finally passing. 🙂 I'll check Mockery and Prophecy next, to (hopefully) enable a stable release of php-mock/php-mock-integration.

@crocodele
Copy link
Contributor Author

crocodele commented Mar 8, 2025

@michalbundyra, the tests in php-mock/php-mock-mockery and php-mock/php-mock-prophecy pass using php-mock/php-mock-integration 2.5.0-beta1, without any code changes. So it looks like the changes in 2.5.0-beta1 are breaking only for php-mock/php-mock-phpunit.

If this is enough in terms of testing, I think the remaining steps would be:

  1. Release php-mock/php-mock-integration 3.0.0.
  2. Bump the php-mock/php-mock-integration dependency to ^3.0.0 in this PR.
  3. Create PRs in php-mock/php-mock-mockery and php-mock/php-mock-prophecy to widen the php-mock/php-mock-integration dependency to ^2.2.1 || ^3.0.0.
  4. Review PRs, iterate if needed, merge the PRs and release new versions. 🙂

@michalbundyra michalbundyra marked this pull request as ready for review March 8, 2025 19:54
@michalbundyra michalbundyra added this to the 2.11.0 milestone Mar 8, 2025
@michalbundyra michalbundyra merged commit e01b288 into php-mock:master Mar 8, 2025
128 checks passed
@michalbundyra
Copy link
Member

@crocodele huge thanks 🙇

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.

3 participants