fix(upgrade): actually modernize phpunit XML configs - #56
Merged
Conversation
The upgrade step's XML rewrite has never run: the callback sat behind an early return that only let .php files through, and even if reached, it called String.replace with regex syntax in a plain string — a literal match that hits nothing. Every upgraded extension kept its PHPUnit 9.3-era config, which PHPUnit 12 flags as a deprecation on every run. The rewrite is now a real transform in its own module, converting configs to the shape the CLI scaffolds: schema resolved from the vendored phpunit (relative to the config's own directory, so root-level configs resolve without ../), the attributes PHPUnit 10 removed dropped or renamed (backupStaticAttributes becomes backupStaticProperties with its value kept), cacheDirectory and displayDetailsOnTestsThatTriggerWarnings inserted in scaffold order so flarum/testing's query guard warnings surface in output, coverage's include list moved to <source>, and the Mockery listeners block removed. Testsuites and per-file settings are preserved, and the transform is idempotent on already-modern configs. Root-level phpunit.xml files are now targeted alongside tests/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug — the XML rewrite has never run
Found while modernizing fof/synopsis's configs by hand (FriendsOfFlarum/synopsis#7) and asking why the upgrade tool hadn't already done it. Two independent defects, either fatal alone:
So every extension run through
upgrade:2.0kept its PHPUnit 9.3-era config — which PHPUnit 12 tolerates but flags as a deprecation on every run, hides query-guard warnings behind summary counts, and pins the schema to a URL that no longer matches the installed phpunit.The fix
modernizePhpunitXml()in its own dependency-free module, wired through a restructured dispatch (.phpandphpunit*.xmleach get their own path; root-levelphpunit.xmladded to targets). The transform converts to the shape this CLI scaffolds:tests/…→../vendor/…, root →vendor/…)backupStaticAttributes→backupStaticPropertieskeeping its valuecacheDirectory+displayDetailsOnTestsThatTriggerWarningsinserted in scaffold order<coverage>→<source>(include list preserved);<listeners>removedVerification