[PR #10990] Allow creating mocks of the Query class #12742

Open
opened 2026-01-22 16:15:02 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/10990

State: closed
Merged: Yes


Replaces #10957.

This change allows mocking the query builder even with the native return types added in 3.0. While we do not recommend or encourage to mock the query builder, I believe we should not actively prevent this kind of test.

This change also allows us to create mocks of the Query class and intercept calls to the Query::execute() method. The presence of the method shows us that the Query is not a pure value object, so intercepting this kind of call might be reasonable to a certain degree.

**Original Pull Request:** https://github.com/doctrine/orm/pull/10990 **State:** closed **Merged:** Yes --- Replaces #10957. This change allows mocking the query builder even with the native return types added in 3.0. While we do not recommend or encourage to mock the query builder, I believe we should not actively prevent this kind of test. This change also allows us to create mocks of the `Query` class and intercept calls to the `Query::execute()` method. The presence of the method shows us that the `Query` is not a pure value object, so intercepting this kind of call might be reasonable to a certain degree.
admin added the pull-request label 2026-01-22 16:15:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12742