test(attribute): assert subclass hydration through the public API - #966
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
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>
7f503c5 to
cd47b71
Compare
What
The three attribute-hydration tests in
tests/unit/AttributeSubclassTest.phpreached past the public surface: they stubbed theAdapter, then invoked the privateDatabase::createDocumentInstance()throughReflectionMethod. 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
Memoryadapter and read it back withgetDocument(), via a smallstore()helper. Same three properties are covered:testReadingBackHydratesTheMappedSubclass— the mapped document type hydrates to that subclass.testReadingBackHydratesTheSubclassTheStoredTypeNames— withAttribute::classmapped, the storedtypeselects the subclass.testStoredTypeWinsOverTheMappedClass— a storedIntegertype beats a mappedStringType.This removes the last
Reflectionusage from the file.Verification
vendor/bin/phpunit tests/unit/AttributeSubclassTest.php— OK (174 tests, 697 assertions)composer lint— passedTests only; no production code touched.
🤖 Generated with Claude Code