Skip to content

test(attribute): assert subclass hydration through the public API - #966

Merged
abnegate merged 1 commit into
feat-query-libfrom
test/attribute-subclass-public-api
Sep 11, 2026
Merged

test(attribute): assert subclass hydration through the public API#966
abnegate merged 1 commit into
feat-query-libfrom
test/attribute-subclass-public-api

Conversation

@abnegate

Copy link
Copy Markdown
Member

What

The three attribute-hydration tests in tests/unit/AttributeSubclassTest.php reached past the public surface: they stubbed the Adapter, then invoked the private Database::createDocumentInstance() through ReflectionMethod. That asserted the shape of an internal method, not the behaviour callers depend on — renaming the method would have broken the tests while the feature stayed correct, and a regression anywhere else in the read path would have gone unnoticed.

They now write one attribute row to the Memory adapter and read it back with getDocument(), via a small store() helper. Same three properties are covered:

  • testReadingBackHydratesTheMappedSubclass — the mapped document type hydrates to that subclass.
  • testReadingBackHydratesTheSubclassTheStoredTypeNames — with Attribute::class mapped, the stored type selects the subclass.
  • testStoredTypeWinsOverTheMappedClass — a stored Integer type beats a mapped StringType.

This removes the last Reflection usage from the file.

Verification

  • vendor/bin/phpunit tests/unit/AttributeSubclassTest.php — OK (174 tests, 697 assertions)
  • composer lint — passed

Tests only; no production code touched.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • 0.69.x

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7f1824f2-db11-4940-8a6f-f2e2175818a4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The test-only PR appears safe to merge, with no outstanding correctness or repository-rule issues.

Summary

  • Persists attribute rows using the Memory adapter and reads them with getDocument().
  • Verifies mapped-subclass hydration, stored-type subclass selection, and stored-type precedence.
  • Corrects the previously reported test-name wording issue.

Reviews (2) · Last reviewed commit: "test(attribute): assert subclass hydrati..."

Comment thread tests/unit/AttributeSubclassTest.php Outdated
The three hydration tests reached past the public surface: they stubbed the
adapter and invoked the private createDocumentInstance() by reflection, so
they asserted the shape of an internal method rather than the behaviour
callers depend on. A rename of that method would have broken them while the
feature stayed correct, and a regression in the surrounding read path would
have gone unnoticed.

Write one attribute row to the Memory adapter and read it back with
getDocument(). Subclass hydration is now observed where it matters, and the
last reflection in the file is gone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@abnegate
abnegate force-pushed the test/attribute-subclass-public-api branch from 7f503c5 to cd47b71 Compare September 11, 2026 05:39
@abnegate
abnegate merged commit de0b14b into feat-query-lib Sep 11, 2026
22 checks passed
@abnegate
abnegate deleted the test/attribute-subclass-public-api branch September 11, 2026 05:51
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