Repository navigation
test(bridge): cover associations between woven Doctrine entities - #773
Merged
Merged
Conversation
Issue #327 reported that under the 3.x extend-based engine the mapping attributes ended up on the renamed parent class (Entity__AopProxied): the table name got the suffix, every association pointed at the parent, joins were built with mismatched aliases and lazy loading was broken. The trait-based engine keeps the mapping on the woven class itself. Add two associated fixture entities (bidirectional one-to-many/many-to-one, every public method advised) and a fixture script that runs them through Doctrine ORM against in-memory SQLite: schema, persist, a DQL join, lazy loading of the many-to-one side as a native lazy object and of the collection. The functional test asserts table names, association targets, the exact SQL and that advices run only for user code. Closes #327 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dKKrvU4XVsKSfKRXPpwUS
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #773 +/- ##
=========================================
Coverage 98.19% 98.19%
Complexity 1910 1910
=========================================
Files 113 113
Lines 4995 4995
=========================================
Hits 4905 4905
Misses 90 90 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The 3.x metadata listener special-cased mappings imported from traits (Gedmo Timestampable, Blameable) because they were duplicated between the renamed parent and the proxy. Under the trait-based engine the column is mapped once on the woven class: Sensor now uses TimestampableTrait, and the association test asserts the column, its hydration through the lazy object and the advised accessor. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dKKrvU4XVsKSfKRXPpwUS
lisachenko
commented
Oct 22, 2026
The details live in the test docblock and the fixture script headers. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dKKrvU4XVsKSfKRXPpwUS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Re-check of the oldest open issue, #327 ("Doctrine entities could not be woven"). The issue was caused by the 3.x extend-based engine: the mapping attributes stayed on the renamed parent class
Entity__AopProxied, so Doctrine mapped that class (table suffix__aop_proxied, associations pointing at the parent, mismatched SQL aliases in joins, broken lazy loading). The mapped-superclass workaround from the thread (commit 6e2a0fe, the 3.xMetadataLoadInterceptor) could not handle inverse one-to-many sides and had to strip mappings imported from traits (Gedmo Timestampable/Blameable) to avoid duplicates between parent and proxy. #334 (woven entities missing fromdoctrine:schema:update) was folded into it and is whatWovenEntityClassLocatorfixed in #671.The 4.0 trait-based engine keeps the mapping on the woven class itself (the original body moves into a trait Doctrine never maps). This PR adds the regression coverage that was missing for the scenarios of the thread, so #327 can be closed with evidence:
Sensor/SensorValuewith a bidirectional one-to-many / many-to-one, every public method advised (EntityFieldAspect).SensorusesTimestampableTrait, which maps a column the Gedmo way.tests/Fixtures/project/bin/doctrine-associations.phpruns them through Doctrine ORM 3.7 against in-memory SQLite: schema, persist with cascade, a DQL join, lazy loading of the many-to-one side as a native lazy object and lazy loading of the collection, logging every SQL statement.DoctrineBridgeTest::testDoctrineMapsAssociationsBetweenWovenEntitiesasserts table names, association targets, no mapped superclass, the trait-mapped column, the exact join and collection-load SQL (consistent aliases) and that advices run for user code only. Skipped whenpdo_sqliteis missing.Closes #327
Checklist
type(scope): summary)composer checkpasses🤖 Generated with Claude Code
https://claude.ai/code/session_018dKKrvU4XVsKSfKRXPpwUS