HP-2693: Upgrade PHPUnit to v12#107
Conversation
WalkthroughBumped dev requirements in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
composer.json (1)
85-98: Minimum-stability=dev without prefer-stable increases solver churn and pulls dev branches.Given many dev-master hiqdev packages, you may need minimum-stability=dev, but you should still prefer stable to reduce accidental dev-main selections (the root cause here).
Apply:
"minimum-stability": "dev", + "prefer-stable": true,If feasible long-term, migrate off dev-master constraints to tagged releases and drop minimum-stability entirely. I can help propose a phased plan.
🧹 Nitpick comments (1)
composer.json (1)
79-84: Move tests namespace to autoload-dev to keep prod autoload lean.Currently tests are included in the main autoload section. Shift them to autoload-dev to avoid exposing test classes in production contexts.
"autoload": { "psr-4": { "hiqdev\\php\\billing\\": "src", - "hiqdev\\php\\billing\\tests\\": "tests" } }, + "autoload-dev": { + "psr-4": { + "hiqdev\\php\\billing\\tests\\": "tests" + } + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
composer.json(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: behat-tests
composer.json
[error] 1-1: Command: composer install -n failed. Your requirements could not be resolved to an installable set of packages: phpunit/phpunit (^12.0) requires sebastian/diff ^7.0.0, but conflict analysis indicates no installable combination (dev-main).
🪛 GitHub Actions: phpunit-tests
composer.json
[error] 1-1: Command 'composer install -n' failed: Your requirements could not be resolved to an installable set of packages. Root composer.json requires phpunit/phpunit ^12.0 and vimeo/psalm ^5.0; phpunit/phpunit 12.x requires sebastian/diff ^7.0.0, but a conflict with sebastian/diff dev-main prevents installation.
🪛 GitHub Actions: Psalm Static Analysis
composer.json
[error] 1-1: Step 'composer install -n' failed: Your requirements could not be resolved to an installable set of packages. phpunit/phpunit ^12.0 requires sebastian/diff ^7.0.0; conflict with sebastian/diff dev-main (alias) prevents install.
🔇 Additional comments (1)
composer.json (1)
55-55: Enable stable dependency resolution and pin sebastian/diff
- In composer.json, add
"prefer-stable": truealongside your existing"minimum-stability": "dev"- Under
"require-dev", insert"sebastian/diff": "^7.0"to satisfy PHPUnit 12’s requirement- After updating, run
composer installthencomposer why sebastian/diffto uncover any remaining dev-main pulls and confirm a clean solve
| "ext-intl": "*", | ||
| "behat/behat": "^3.4.3", | ||
| "phpunit/phpunit": "^10.0.0", | ||
| "phpunit/phpunit": "^12.0", |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Sanity-check PHPUnit 12 ecosystem constraints before merging.
PHPUnit 12 may raise minimum PHP or sebastian/* requirements compared to v10. Validate your runtime/tooling matrix and deprecations in the test suite (e.g., removed APIs, annotations).
🌐 Web query:
What PHP version and sebastian/* package versions does phpunit/phpunit 12.x require? List notable breaking changes from PHPUnit 11->12.
💡 Result:
Short answer
- PHP: PHPUnit 12 requires PHP >= 8.3. [1]
- sebastian/* (representative required versions in PHPUnit 12.x composer):
- sebastian/cli-parser: ^4.0.0
- sebastian/comparator: ^7.0.1
- sebastian/diff: ^7.0.0
- sebastian/environment: ^8.0.1
- sebastian/exporter: ^7.0.0
- sebastian/global-state: ^8.0.0
- sebastian/object-enumerator: ^7.0.0
- sebastian/type: ^6.0.2
- sebastian/version: ^6.0.0
(See composer.json for full dependency list / exact minor versions.) [2]
Notable breaking changes when upgrading from PHPUnit 11 → 12
- PHP requirement raised to PHP ≥ 8.3 (you cannot install PHPUnit 12 on older PHP). [1]
- Annotation (doc‑comment) metadata support removed — migrate all @test, @before, @after, @dataProvider, etc. to PHP attributes. (Annotations were deprecated in PHPUnit 11 and removed in 12.) [1][3]
- Test‑double API cleanup and removals:
- Methods for creating mocks/stubs for abstract classes and traits removed (previously deprecated). [1][4]
- Configuring expectations on objects created with createStub() no longer works (was deprecated earlier). [1][4]
- TestCase helper methods that returned stub configuration objects (returnValue, returnValueMap, onConsecutiveCalls, returnArgument, returnSelf, returnCallback, etc.) were removed — use the shorthand willReturn/willReturnMap/willReturnCallback/etc. instead. [4]
- Functionality that was only soft‑deprecated in PHPUnit 11 is hard‑deprecated/removed in 12 — run your suite under PHPUnit 11.5 and fix deprecation warnings before upgrading. [1]
Sources
- PHPUnit 12 release announcement / requirements and major changes. [phpunit.de announcement]. [1]
- PHPUnit 12.x composer.json dependency snapshot (shows PHP platform and sebastian/* constraints). [composer.json diff / package listing]. [2]
- Notes / guidance on removing doc‑comment metadata and migrating to attributes. [community article / PHPUnit docs]. [3]
- Issue / PR tracking removal of TestCase return* methods and other test‑double removals. [GitHub issue]. [4]
If you want, I can paste the exact composer.json dependency block for PHPUnit 12.x (or link to the tag) so you can copy the exact constraints.
composer.json (line 55): require PHP ≥ 8.3 and bump sebastian/ deps for PHPUnit 12*
Update the PHP requirement to >=8.3 and set sebastian/cli-parser to ^4.0.0, comparator to ^7.0.1, diff to ^7.0.0, environment to ^8.0.1, exporter to ^7.0.0, global-state to ^8.0.0, object-enumerator to ^7.0.0, type to ^6.0.2, and version to ^6.0.0. Migrate all annotations (@test, @before, @after, @dataProvider, etc.) to PHP 8 attributes and replace removed TestCase stub helpers (returnValue*, returnValueMap, onConsecutiveCalls, returnArgument, returnSelf, returnCallback, etc.) with the willReturn* shorthands. Run your suite under PHPUnit 11.5 to clear deprecation warnings before upgrading.
🤖 Prompt for AI Agents
In composer.json around line 55, update the PHP platform requirement to ">=8.3"
and add explicit version constraints for the sebastian packages required by
PHPUnit 12 (set sebastian/cli-parser to ^4.0.0, sebastian/comparator to ^7.0.1,
sebastian/diff to ^7.0.0, sebastian/environment to ^8.0.1, sebastian/exporter to
^7.0.0, sebastian/global-state to ^8.0.0, sebastian/object-enumerator to ^7.0.0,
sebastian/type to ^6.0.2, and sebastian/version to ^6.0.0); then update test
code by converting PHPUnit annotations (@test, @before, @after, @dataProvider,
etc.) to PHP 8 attributes and replace removed TestCase stub helpers
(returnValue*, returnValueMap, onConsecutiveCalls, returnArgument, returnSelf,
returnCallback, etc.) with the willReturn* shorthands; finally run the test
suite under PHPUnit 11.5, fix any deprecation warnings, then proceed to upgrade
to PHPUnit 12.
…fix composer package compatibility issues
…^12.0` require it
Summary by CodeRabbit
No impact on application features or runtime behavior.