Skip to content

docs: update testing guide for PHPUnit 12 - #526

Merged
imorland merged 1 commit into
mainfrom
im/phpunit-12-docs
Apr 18, 2026
Merged

docs: update testing guide for PHPUnit 12#526
imorland merged 1 commit into
mainfrom
im/phpunit-12-docs

Conversation

@imorland

Copy link
Copy Markdown
Member

Summary

Why

Companion to flarum/framework#4585, which bumps `flarum/testing`'s PHPUnit constraint from `^11.0` to `^12.5.22` to clear GHSA-qrr6-mg7r-m243. The existing docs still show PHPUnit 9-era configs and `@test` docblock annotations — both broken on PHPUnit 10+, and silently broken on PHPUnit 12 (docblock annotations stop registering tests without warning).

testing.md

  • Example `phpunit.integration.xml` / `phpunit.unit.xml` configs rewritten for the PHPUnit 12 schema (drop removed `convertErrorsToExceptions` / `convertNoticesToExceptions` / `convertWarningsToExceptions`, rename `backupStaticAttributes` → `backupStaticProperties`, drop the `` block, add schema declaration and `cacheDirectory`).
  • All five `@test` docblock examples converted to `#[Test]` attributes with the matching `use PHPUnit\Framework\Attributes\Test;` import.
  • Updated PHPUnit documentation links from `phpunit.readthedocs.io/en/9.3/` → `docs.phpunit.de/en/12.5/`.
  • Added a migration callout under the example configs summarising the PHPUnit 12 requirement and pointing at the annotations guide.

update-2_0.md

  • New PHPUnit (updated from ^9.5 to ^12.5) subsection under Infrastructure, matching the PHPStan/Larastan section's breaking/notable formatting.
  • Calls out:
    • Annotations → attributes (with a complete before/after example, note about silent test non-discovery, and pointer to Rector's `ANNOTATIONS_TO_ATTRIBUTES` set).
    • Config schema attribute/element removals.
    • PHPUnit 12's new `AllowMockObjectsWithoutExpectations` notice (advisory, not breaking).

Test plan

  • Rendered locally — no Docusaurus build errors, admonition renders.
  • Reviewer spot-check that the example XML matches what core's tests/phpunit.integration.xml uses.

flarum/testing on 2.x now requires PHPUnit 12. Refresh the testing guide
example configs to PHPUnit 12's schema (the 9.x example was already
broken on PHPUnit 10+), replace @test docblocks in the examples with
#[Test] attributes, and add a dedicated PHPUnit section to the 2.0
update guide covering annotations → attributes, config schema
attribute/element removals, and the new AllowMockObjectsWithoutExpectations
notice.
@imorland
imorland merged commit 5912f67 into main Apr 18, 2026
1 check passed
@imorland
imorland deleted the im/phpunit-12-docs branch April 18, 2026 09:10
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.

1 participant