Skip to content

feat: show test warning details in generated PHPUnit configs - #53

Merged
imorland merged 1 commit into
3.xfrom
im/display-test-warnings
Aug 1, 2026
Merged

feat: show test warning details in generated PHPUnit configs#53
imorland merged 1 commit into
3.xfrom
im/display-test-warnings

Conversation

@imorland

@imorland imorland commented Aug 1, 2026

Copy link
Copy Markdown
Member

Why

Flarum's integration TestCase now inspects each request for N+1 query patterns (flarum/framework#4871). A query run once per record fails the test; one repeated for the same few values raises a warning instead, since it doesn't grow with the forum.

PHPUnit only prints what a warning said when displayDetailsOnTestsThatTriggerWarnings is enabled. Without it a run ends with:

OK, but there were issues!
Tests: 82, Assertions: 344, Warnings: 11.

— visible, but with no indication of which queries or where. Both generated configs now set the flag, so extension authors get the finding itself. Since backendTesting is updatable, existing extensions pick it up by re-running flarum-cli infra backendTesting, not just newly generated ones.

Also: the unit config's schema reference

phpunit.unit.xml pointed at https://schema.phpunit.de/10.5/phpunit.xsd while phpunit.integration.xml used ../vendor/phpunit/phpunit/phpunit.xsd. Flarum 2.x requires PHPUnit ^12.5, so the remote reference was both a version behind what gets installed and dependent on the network to validate. It now matches the integration config — which is also what extensions in the wild use (I checked several standalone 2.x extensions rather than core, whose deeper path in the monorepo isn't representative).

Verification

  • Both configs validate against a real PHPUnit 12.5 phpunit.xsd via xmllint --schema.
  • yarn test — 22 suites, 176 tests, Prettier clean.

… installed phpunit

Flarum's integration TestCase now reports repeated database queries as
PHPUnit warnings — a query run once per record fails the test, one
repeated for the same few values warns instead. PHPUnit only prints the
detail of a warning when displayDetailsOnTestsThatTriggerWarnings is
set; without it a run says 'Warnings: 11' and nothing about what they
were. Both generated configs now set it, so extension authors get the
finding rather than a count.

The unit config also pointed at a remote 10.5 schema while the
integration one used the installed copy. Flarum 2.x requires PHPUnit
^12.5, so the remote reference both drifts from what is installed and
needs the network to validate. It now matches the integration config,
which is what extensions in the wild use.

Both configs validate against a real PHPUnit 12 schema.
@imorland
imorland merged commit b01edc4 into 3.x Aug 1, 2026
3 checks passed
@imorland
imorland deleted the im/display-test-warnings branch August 1, 2026 00:06
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