test: assert rating as a json number across json-streamer versions - #8463
Merged
soyuka merged 1 commit intoAug 16, 2026
Merged
Conversation
api-platform#8461 changed the rating assertions to assertIsFloat/assertSame(0.0), which pins them to json-streamer >= 8.1.4 where JSON_PRESERVE_ZERO_FRACTION is set. The Symfony lowest job resolves an earlier release that encodes an integral float as 5, so the assertions failed there. Assert that the decoded value is a JSON number of either PHP type instead. Verified on json-streamer 8.1.2 and 8.1.4.
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.
Fixes the
PHPUnit (PHP 8.3) (Symfony lowest)job, which #8461 broke.What broke
#8461 adapted the
ratingassertions to json-streamer 8.1.4, which encodes withJSON_PRESERVE_ZERO_FRACTION:That pins the test to >= 8.1.4. The
Symfony lowestjob runscomposer update --prefer-lowest, which resolves an earlier json-streamer that encodes an integral float as5:Symfony lowestwas green one22463fdband red frome3cb2da6c(#8461), so this is a clean regression rather than a pre-existing condition.Fix
The PHP type of a decoded JSON number is an encoder detail that varies by version; the assertion should not depend on it. Assert that it is a JSON number of either type:
and compare the write-path value loosely (
assertEquals(0, ...)) so0and0.0both satisfy it.views(a realint) andprice(astring) keep their strict assertions.Verification
Reproduced the failure locally by downgrading to json-streamer 8.1.2 — the assertions on 4.3 fail exactly as CI reports:
With this change,
phpunit tests/Functional --filter JsonStreamerpasses under both json-streamer 8.1.2 and 8.1.4 (7 tests, 41 assertions, 1 skipped).composer.jsonrestored afterwards; only the test file changes.