Skip to content

fix(test): restore main CI after the ApiTestCase extraction - #8526

Merged
soyuka merged 4 commits into
api-platform:mainfrom
soyuka:fix/main-apitestcase-bc
Sep 11, 2026
Merged

fix(test): restore main CI after the ApiTestCase extraction#8526
soyuka merged 4 commits into
api-platform:mainfrom
soyuka:fix/main-apitestcase-bc

Conversation

@soyuka

@soyuka soyuka commented Sep 11, 2026

Copy link
Copy Markdown
Member

main is currently red: 24 failing jobs on c587c81e0. Two distinct causes, both from PRs merged earlier today on stale CI runs — neither is merge-up damage. The merge-up simply made main complete a CI run for the first time since 150911ef7.

1. ApiTestCase FQCN fatal — takes down the whole matrix

Internal error: Class "ApiPlatform\Symfony\Bundle\Test\ApiTestCase" not found

#7887 moved the test helpers to ApiPlatform\Test and deleted src/Symfony/Bundle/Test/. 11 files still used the old FQCN — some merged on main after #7887 (#8283, #8310, #7870, #8491), some brought up from 4.3/4.4 (#8451, #8505, #8416, #8521, #8508), where the old FQCN is still correct. One fatal killed every PHPUnit job and PHPStan.

2. GraphiQL csp_nonce double — graphql x4

EntrypointActionTest::testGetHtmlAction
Prophecy\Exception\Call\UnexpectedCallException:
  Unexpected method call: getFunction("csp_nonce")
  expected calls were: render(* [, ...])

#8310 made GraphiQlAction ask Twig for csp_nonce and updated GraphiQlActionTest, but missed EntrypointActionTest, which builds the same action.

3. Deprecated BC shims (the structural part)

#7887 moved eight public classes with no deprecation path. Users extend ApiTestCase in their own suites, so they hit a bare "class not found" on upgrade. It also breaks every merge-up:

branch old FQCN present files using it
4.3 yes 263
4.4 yes 279
main deleted 11 (fixed here)

Without a shim this recurs on every merge-up until 4.4 reaches EOL. The shims restore all eight at the old FQCNs, each emitting trigger_deprecation:

  • ApiTestCase — abstract, subclassed
  • ClientTrait, ApiTestAssertionsTrait, Constraint\ArraySubsetTrait — traits, wrapped via use
  • Client, Response, Constraint\ArraySubset, Constraint\MatchesJsonSchemafinal, so class_alias (they cannot be subclassed)

Verified at runtime through the real autoloader, not just php -l: all 5 classes resolve to their new counterparts and all 3 traits exist.

api-platform/test and symfony/deprecation-contracts are added to src/Symfony/composer.json, which previously declared neither.

Note on the strict deprecation job

PHPUnit (no deprecations) runs max[self]=0. Nothing fires today since main's own tests now use the new FQCN. A future merge-up that brings an old-FQCN file will trip that job rather than fataling the whole suite — a better failure mode, but it still wants the FQCN rewritten on merge-up. ignoreFile=./tests/.ignored-deprecations is available if you'd prefer to silence it.

Unrelated, spotted while here

api-platform/test is not in the CI component matrix in ci.yml (18 components listed, it isn't one). It ships — it's in the root replace and matched by the pmu glob — but is never tested in isolation. Same gap eb6bd572b had to fix for MCP. Not addressed here.

api-platform#7887 moved the test helpers to ApiPlatform\Test and deleted
src/Symfony/Bundle/Test. 11 test files still referenced the old FQCN,
either merged on main after api-platform#7887 or brought up from 4.3/4.4. The
resulting fatal took down the whole PHPUnit matrix and PHPStan.

Also stubs getFunction('csp_nonce') on the Twig double in
EntrypointActionTest: api-platform#8310 updated GraphiQlActionTest but missed this
one, which builds the same GraphiQlAction.
api-platform#7887 moved eight public classes out of api-platform/symfony without a
deprecation path, so user test suites extending ApiTestCase break on a
plain "class not found". Restore them at the old FQCNs as deprecated
shims delegating to ApiPlatform\Test.

Client, Response, ArraySubset and MatchesJsonSchema are final and
cannot be subclassed, so they are class_alias'd; the traits are wrapped;
ApiTestCase subclasses. Adds api-platform/test and
symfony/deprecation-contracts to the component requirements.
CS Fixer's fully_qualified_strict_types applies to docblocks, so the
{@see} tags must use the imported alias. PHPStan reports trait.unused
for the three trait shims, which exist only for BC and are legitimately
used nowhere in the monorepo.
api-platform#8517 removed the Request::getContentType() fallbacks and the
method_exists() guards around getContentTypeFormat(), but kept the
ignore patterns targeting them, so phpstan reports them as unmatched.
Neither has a call site left.
@soyuka
soyuka merged commit 7afb7c8 into api-platform:main Sep 11, 2026
107 of 117 checks passed
soyuka added a commit that referenced this pull request Sep 11, 2026
#8526 added api-platform/test to require, but it pulls
phpunit ^11.5 || ^12.2 into every production install and breaks the
Guides job, whose docs/composer.json pins phpunit ^10.

4.4 keeps phpunit in require-dev while still shipping the same helpers;
the shims only load from test code, so require-dev plus a suggest entry
matches that precedent.

Claude-Session: https://claude.ai/code/session_01FmRmcWx8J7PS374edGFBdE
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