Skip to content

test(doctrine): adapt unwired filter test to 5.0 - #8501

Merged
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:fix/unwired-filter-test-5.0
Sep 5, 2026
Merged

soyuka merged 1 commit into
api-platform:mainfrom
soyuka:fix/unwired-filter-test-5.0

Conversation

@soyuka

@soyuka soyuka commented Sep 4, 2026

Copy link
Copy Markdown
Member

Problem

UnwiredLegacyFilterParameterTest::testUnwiredRegistryAwareFilterIsLoggedAtDebug is red on main (all linked api-platform/doctrine-orm PHPUnit jobs):

Expectation failed for method name is "debug" when invoked 1 time.
Method was expected to be called 1 time, actually called 0 times.

Cause

The test arrived on main via the 4.4 up-merge and encodes 4.4-specific behaviour.

On 4.4, DateFilter extends AbstractFilter, whose getDescription() throws a RuntimeException when no ManagerRegistry was injected. ParameterResourceMetadataCollectionFactory catches it and logs at debug rather than alert for an unwired ManagerRegistryAwareInterface filter (#8490, closes #7361).

On 5.0, DateFilter is a standalone filter (#8351): it implements ManagerRegistryAwareInterface directly, and getClassMetadata() falls back to new ClassMetadata($resourceClass) when hasManagerRegistry() is false. It never throws, so getLegacyFilterMetadata() succeeds, the catch block is never entered, and neither debug nor alert is called.

That 5.0 behaviour is correct and still satisfies #7361 — it avoids the warmup noise by not failing at all, rather than by downgrading the log level.

Change

Test-only. The first case now asserts the actual 5.0 contract (nothing is logged) and is renamed accordingly. testFilterFailureUnrelatedToTheManagerRegistryStillAlerts is untouched and still pins the alert path for an unrelated filter failure.

vendor/bin/phpunit src/Doctrine/Orm/Tests/Metadata/Resource/UnwiredLegacyFilterParameterTest.php
OK (2 tests, 2 assertions)

No production code changed.

The test came up from 4.4, where DateFilter extends AbstractFilter and
its getDescription() throws when no ManagerRegistry was injected, so
ParameterResourceMetadataCollectionFactory catches it and downgrades
the log to debug. On 5.0 DateFilter is standalone and getClassMetadata()
falls back to a bare ClassMetadata instead of throwing, so the catch
never runs and nothing is logged at all -- which still satisfies api-platform#7361.
@soyuka
soyuka merged commit 74bef19 into api-platform:main Sep 5, 2026
105 of 113 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.

Declaring a filter via Parameter logs an exception

1 participant