Skip to content

test: test AbstractSimpleAggregation with a real subclass and run it in CI - #2334

Open
ruflin wants to merge 1 commit into
9.xfrom
fix/abstract-aggregation-test
Open

ruflin wants to merge 1 commit into
9.xfrom
fix/abstract-aggregation-test

Conversation

@ruflin

@ruflin ruflin commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Summary

AbstractSimpleAggregationTest built its subject with createMock(AbstractSimpleAggregation::class). PHPUnit stubs every method on a mock, including toArray(), which is the method under test. The stub returned nothing, so the expected InvalidException was never thrown.

The fix uses a real anonymous subclass with no params set, so toArray() runs its own validation. Two related gaps are fixed too:

  • The class overrode setUp() without calling parent::setUp(), which skipped Base::setUp's group check.
  • It declared no group, so no CI group ran it.

It now calls the parent setUp() and declares #[Group('unit')].

Red then green

  • Before: --filter=AbstractSimpleAggregationTest fails with Failed asserting that exception of type "Elastica\Exception\InvalidException" is thrown.
  • After: the same filter passes (OK (1 test, 3 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): this test passes. The remaining failures are MappingTest and JSONTest, which have their own PRs.
  • PHP-CS-Fixer, PHPStan and Rector pass.

No CHANGELOG entry: test-only.

createMock() stubs every method, including toArray(), which is the method
under test. The mock returned null, so the expected InvalidException was
never thrown.

The class also overrode setUp() without calling parent::setUp(), which
skipped Base::setUp's group check, and it declared no group. Call the parent
setUp and declare the unit group so CI runs it.

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