Skip to content

test: fix JSONTest assertion and make it run in CI - #2332

Open
ruflin wants to merge 1 commit into
9.xfrom
fix/json-test-assertion
Open

ruflin wants to merge 1 commit into
9.xfrom
fix/json-test-assertion

Conversation

@ruflin

@ruflin ruflin commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Summary

JSONTest::testStringifyMustNotThrowExceptionOnValid asserts that JSON::stringify([]) is empty. json_encode([]) returns "[]", so the assertion always failed. This asserts the actual encoding instead.

The class also extended TestCase directly, so Base::setUp's group check never ran and no CI group included it. It now extends Base and declares #[Group('unit')], so it runs in CI's unit group. AGENTS.md named JSONTest as an exception to the base-class rule; that line now covers only ClientConfigurationTest.

Red then green

  • Before: --filter=JSONTest fails with Failed asserting that a string is empty.
  • After: --filter=JSONTest passes (OK (3 tests, 8 assertions)).

This is a test-only change with no src/ fix, so the red/green rule in AGENTS.md doesn't apply directly.

Verification

  • Full suite (make docker-run-phpunit): JSONTest passes. The remaining failures are MappingTest and AbstractSimpleAggregationTest, which have their own PRs.
  • PHP-CS-Fixer and PHPStan pass.

No CHANGELOG entry: test-only.

json_encode([]) returns "[]", so asserting the result is empty always
failed. Assert the actual encoding instead.

JSONTest also extended TestCase directly, so Base::setUp's group check never
ran and the class was not in any CI group. Extend Base and declare the unit
group. Update AGENTS.md, which named JSONTest as an exception.

This branch has not been deployed

No deployments
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