Skip to content

test(state): mark the deprecated serializer-aware provider test#8426

Open
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:fix/serializer-aware-provider-deprecation
Open

test(state): mark the deprecated serializer-aware provider test#8426
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:fix/serializer-aware-provider-deprecation

Conversation

@soyuka

@soyuka soyuka commented Jul 27, 2026

Copy link
Copy Markdown
Member

Fixes the PHPUnit (PHP 8.5) (no deprecations) job, which runs vendor/bin/phpunit --fail-on-deprecation --display-deprecations and currently reports:

1 test triggered 1 deprecation:

1) src/State/SerializerAwareProviderTrait.php:33
Since api-platform/core 4.2: The "ApiPlatform\State\SerializerAwareProviderInterface" interface is
deprecated and will be removed in 5.0. It violates the dependency injection principle.

Triggered by:

* ApiPlatform\Tests\Functional\JsonLd\SerializableItemDataProviderTest::testGetSerializableResource

Why

The SerializableProvider test fixture implements SerializerAwareProviderInterface. DataProviderPass therefore adds a setSerializerLocator() method call to its definition, and the trait triggers the 4.2 deprecation when the service is instantiated during the request.

The deprecation is correct and intentional — the interface still ships in 4.3 and is only removed in 5.0, so the code path must stay covered. Only the test needs to declare that it exercises a deprecated feature.

Change

#[IgnoreDeprecations] plus expectUserDeprecationMessage() on the test, following the convention already used in tests/Functional/EnumDenormalizationValidationTest.php. Using the expectation rather than a bare ignore keeps the deprecation asserted, so it will be noticed when the interface is dropped in 5.0.

Verified locally

Run Before After
--fail-on-deprecation --display-deprecations with ignoreIndirectDeprecations="false" reproduces the CI message verbatim OK (1 test, 3 assertions)
same, with the committed config silent OK (1 test, 3 assertions)

The expectation is satisfied under both settings, so it does not depend on how the deprecation is categorised.

Note: this is the only remaining red check on #8425.

SerializableProvider implements SerializerAwareProviderInterface, so
DataProviderPass injects the serializer locator and the trait triggers
its 4.2 deprecation when the service is instantiated. That makes the
"no deprecations" job fail on a deprecation we ship on purpose until
5.0.

Declare the expected deprecation on the test instead of dropping the
fixture, so the deprecated code path stays covered.
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