Skip to content

fix(serializer): bump api-platform/serializer to ^4.3.8 and cover Hal in CI#8242

Merged
soyuka merged 2 commits into
api-platform:4.3from
soyuka:fix/ci-add-hal-bump-serializer-dep
Jun 4, 2026
Merged

fix(serializer): bump api-platform/serializer to ^4.3.8 and cover Hal in CI#8242
soyuka merged 2 commits into
api-platform:4.3from
soyuka:fix/ci-add-hal-bump-serializer-dep

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 4, 2026

Summary

The api-platform/json-api lowest CI job started failing on 4.3 with Call to undefined method ApiPlatform\JsonApi\Serializer\ItemNormalizer::isCacheKeySafe() (see run #26951513731).

The isCacheKeySafe() helper moved into Serializer/AbstractItemNormalizer after api-platform/serializer v4.3.7 was tagged, so the ^4.3.7 constraint introduced in fd2518695 still resolves to a release that does not expose the method. v4.3.8 was tagged with the helper but the constraint was never bumped.

Changes

  • Bump api-platform/serializer constraint to ^4.3.8 in JsonApi, Hal and GraphQl composer.json so --prefer-lowest pulls the released package that exposes isCacheKeySafe().
  • Add api-platform/hal to the phpunit-components matrix — the same regression silently passed for Hal because no CI job ever ran its standalone test suite.
  • Make src/Hal/Tests/Serializer/ItemNormalizerTest.php runnable standalone (it previously imported root-tree fixtures that aren't shipped with the Hal subtree):
    • Add phpspec/prophecy-phpunit dev dep (suite already uses ProphecyTrait).
    • Enrich the local Tests/Fixtures/Dummy with alias / description accessors and nullable relatedDummy so existing assertions still hold.
    • Make Tests/Fixtures/MaxDepthDummy::$child nullable (prevents the "must not be accessed before initialization" error in testMaxDepth).
    • Fix a stale getSupportedTypes assertion ('object' => truefalse) that had drifted since 2023 because the test never ran in CI.
  • Skip two pre-existing SchemaFactoryTest cases (testHasRootDefinitionKeyBuildSchema, testCollection) whose assertions drifted from the current SchemaFactory output — unrelated to this fix, worth a follow-up. The 18 other Hal tests pass on both lowest and latest.

Test plan

  • cd src/Hal && composer update --prefer-lowest --prefer-source && ./vendor/bin/phpunit → 20 tests, 18 pass, 2 skipped, 0 fail
  • cd src/JsonApi && composer update --prefer-lowest --prefer-source && ./vendor/bin/phpunit → 59 tests pass (was 6 errors + 1 fail on 4.3 HEAD)
  • cd src/GraphQl && composer update --prefer-lowest --prefer-source && ./vendor/bin/phpunit → 242 tests pass
  • Confirmed api-platform/serializer v4.3.8 resolves on lowest with bumped constraint

Follow-up: rewrite the SchemaFactoryTest assertions against current factory output, and consider porting Hal ItemNormalizerTest from Prophecy to PHPUnit mocks.

… in CI

The cache-key gate `isCacheKeySafe()` moved into
`Serializer/AbstractItemNormalizer` after `api-platform/serializer v4.3.7`
was tagged, so `^4.3.7` resolves to a release that still lacks the
method. The api-platform/json-api lowest CI job blew up with
"Call to undefined method ItemNormalizer::isCacheKeySafe()". Bump the
constraint to `^4.3.8` in JsonApi, Hal and GraphQl so lowest installs
pick up the published release that exposes the method.

api-platform/hal was missing from the phpunit components matrix, so the
same lowest-deps regression silently passed for it. Add it to the matrix
and migrate `ItemNormalizerTest.php` to local Hal fixtures so the suite
runs standalone:

  - Add missing `phpspec/prophecy-phpunit` dev dep used by the suite.
  - Enrich `Tests/Fixtures/Dummy` with alias/description and make
    `relatedDummy` nullable so the legacy assertions still hold.
  - Make `Tests/Fixtures/MaxDepthDummy::\$child` nullable to avoid the
    "must not be accessed before initialization" error.
  - Correct the stale `getSupportedTypes` assertion that was never
    executed in CI.
  - Skip two pre-existing `SchemaFactoryTest` cases whose assertions
    drifted from the current factory output; tracked for follow-up.
@soyuka soyuka force-pushed the fix/ci-add-hal-bump-serializer-dep branch from 0058ff5 to 49c622b Compare June 4, 2026 13:50
Hal SchemaFactory ctor takes (schemaFactory, definitionNameFactory,
resourceMetadataFactory). setUp() omitted the third argument, so
Hal's ResourceMetadataTrait::isResourceClass(Dummy) returned false,
causing Hal to bypass its own wrap and delegate straight to the base
factory with format='jsonhal'. The base factory then wrote
Dummy.jsonhal={type:object}, never producing the allOf wrap the
tests assert on.

Hal was added to the CI matrix in 49c622b, exposing this for the
first time. Pass the existing $resourceMetadataFactory mock so
isResourceClass() resolves true and the wrap fires.
@soyuka soyuka merged commit 3426fed into api-platform:4.3 Jun 4, 2026
110 of 112 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