Skip to content

test(bridge): cover associations between woven Doctrine entities - #773

Merged
lisachenko merged 3 commits into
masterfrom
feature/focused-brahmagupta-d8a6bz
Oct 22, 2026
Merged

lisachenko merged 3 commits into
masterfrom
feature/focused-brahmagupta-d8a6bz

Conversation

@lisachenko

@lisachenko lisachenko commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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.x MetadataLoadInterceptor) 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 from doctrine:schema:update) was folded into it and is what WovenEntityClassLocator fixed 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:

  • Two new fixture entities Sensor / SensorValue with a bidirectional one-to-many / many-to-one, every public method advised (EntityFieldAspect). Sensor uses TimestampableTrait, which maps a column the Gedmo way.
  • tests/Fixtures/project/bin/doctrine-associations.php runs 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::testDoctrineMapsAssociationsBetweenWovenEntities asserts 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 when pdo_sqlite is missing.
  • The existing metadata test now expects the three fixture entities.

Closes #327

Checklist

  • The title follows Conventional Commits (type(scope): summary)
  • Tests cover the change
  • composer check passes
  • User-facing or breaking changes are in CHANGELOG.md (and the upgrade guide for breaking changes) — tests only, no user-facing change

🤖 Generated with Claude Code

https://claude.ai/code/session_018dKKrvU4XVsKSfKRXPpwUS

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

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.19%. Comparing base (1fac17e) to head (153663e).
⚠️ Report is 4 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
Comment thread src/Core/AGENTS.md Outdated
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
@lisachenko
lisachenko marked this pull request as ready for review October 22, 2026 00:16
@lisachenko
lisachenko merged commit ea73099 into master Oct 22, 2026
14 checks passed
@lisachenko
lisachenko deleted the feature/focused-brahmagupta-d8a6bz branch October 22, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Known-issue] Doctrine entities could not be woven

2 participants