Skip to content

test(parameters): skip the uri variable test before schema setup - #8528

Merged
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:fix/mongodb-urivariable-schema
Sep 11, 2026
Merged

test(parameters): skip the uri variable test before schema setup#8528
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:fix/mongodb-urivariable-schema

Conversation

@soyuka

@soyuka soyuka commented Sep 11, 2026

Copy link
Copy Markdown
Member

Fixes PHPUnit (PHP 8.5) (MongoDB), the last non-release-lag failure on main.

The bug

Doctrine\Persistence\Mapping\MappingException:
  Class 'ApiPlatform\Tests\Fixtures\TestBundle\Document\Base64UriVariableDummy' does not exist

setUp() calls recreateSchema([Base64UriVariableDummy::class, Dummy::class]). Under ODM, RecreateSchemaTrait rewrites \Entity\ to \Document\ and calls dropDocumentCollection() on the result — but only tests/Fixtures/TestBundle/Entity/Base64UriVariableDummy.php exists.

Both tests already intended to skip on MongoDB. The guards just sat inside the test bodies, which PHPUnit reaches only after setUp() has already thrown:

protected function setUp(): void
{
    $this->recreateSchema([...]);   // blows up here
}

public function testLinkParameterProviderDecodesUriVariableBeforeQuery(): void
{
    if ('mongodb' === $container->getParameter('kernel.environment')) {
        $this->markTestSkipped();   // never reached
    }

So the fix is to hoist the author's own guard into setUp() and drop the two now-dead in-body copies.

Why not add the missing ODM fixture

Because guard placement, not fixture parity, is the established convention here. 31 Entity fixtures passed to recreateSchema() across the suite have no Document/ counterpart, and only this one test fails — the other 30 sit in tests that guard before the schema call. Adding a Document/Base64UriVariableDummy.php would make this test inconsistent with 30 existing cases and would create an ODM fixture for a feature the author deliberately chose not to exercise on ODM.

Pre-existing, not new

Introduced by #8491 and merged red on 2026-09-02. It was invisible on main only because #7887's bootstrap fatal (Class "ApiPlatform\Symfony\Bundle\Test\ApiTestCase" not found) aborted the suite before this job could report. Two runs nine days apart show the identical two errors:

run date result
33624793541 (#8491's own CI) 2026-09-02 Tests: 2061 … Errors: 2
34615693926 (today) 2026-09-11 Tests: 2121 … Errors: 2

Checks

php -l clean. CS Fixer reports 0 of 3024 files to fix. PHPStan on this file is unchanged by the diff — 4 pre-existing unknown class entries from local Doctrine resolution before and after, line numbers shifted only.

https://claude.ai/code/session_01FmRmcWx8J7PS374edGFBdE

setUp() calls recreateSchema(), which rewrites \Entity\ to \Document\
under ODM, but Base64UriVariableDummy has no ODM counterpart. Both
tests already meant to skip on mongodb; the guards just sat in the test
bodies, which run after setUp() has failed.

Claude-Session: https://claude.ai/code/session_01FmRmcWx8J7PS374edGFBdE
@soyuka
soyuka force-pushed the fix/mongodb-urivariable-schema branch from aac7586 to 051781d Compare September 11, 2026 19:47
@soyuka
soyuka merged commit 1937ccd into api-platform:main Sep 11, 2026
9 of 115 checks passed
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