getQueryResult #5250

Closed
opened 2026-01-22 15:02:38 +01:00 by admin · 3 comments
Owner

Originally created by @DonCallisto on GitHub (Sep 12, 2016).

Why don't add the following API to QueryBuilder?

public function getQueryResult($hydrationMode = null)
{
    return $this->getQuery()->getResult($hydrationMode);
}

That way Law of Demeter is not broken and is easier to write tests mocking QueryBuilder.

Other way I need to create a mock of Query (and, perhaps, it's not possibile with Prophecy as Query is final) so it force me to "dig" into collaborator structure.

Any thoughts?

Originally created by @DonCallisto on GitHub (Sep 12, 2016). Why don't add the following API to `QueryBuilder`? ``` public function getQueryResult($hydrationMode = null) { return $this->getQuery()->getResult($hydrationMode); } ``` That way Law of Demeter is not broken and is easier to write tests mocking `QueryBuilder`. Other way I need to create a mock of `Query` (and, perhaps, it's not possibile with Prophecy as `Query` is final) so it force me to "dig" into collaborator structure. Any thoughts?
admin closed this issue 2026-01-22 15:02:39 +01:00
Author
Owner

@guilherme90 commented on GitHub (Jun 13, 2017):

Yes, I'm having the same problem with mock the Query object (it is not possible to create fake objects with final signature). And when I do this with AbstractQuery, it gives a constructor error.

How can we solve this?

@guilherme90 commented on GitHub (Jun 13, 2017): Yes, I'm having the same problem with mock the `Query` object (it is not possible to create fake objects with final signature). And when I do this with `AbstractQuery`, it gives a constructor error. How can we solve this?
Author
Owner

@Ocramius commented on GitHub (Jun 13, 2017):

Please don't mock the QueryBuilder or Query objects: use real instances
there.

On 14 Jun 2017 02:30, "Guilherme Nogueira" notifications@github.com wrote:

Yes, I'm having the same problem with mock the Query object (it is not
possible to create fake objects with final signature). And when I do this
with AbstractQuery, it gives a constructor error.

How can we solve this?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6023#issuecomment-308277435,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakLRaBPp1AfrV_pccrADvYyhGRfnzks5sDxuYgaJpZM4J6aKG
.

@Ocramius commented on GitHub (Jun 13, 2017): Please don't mock the QueryBuilder or Query objects: use real instances there. On 14 Jun 2017 02:30, "Guilherme Nogueira" <notifications@github.com> wrote: > Yes, I'm having the same problem with mock the Query object (it is not > possible to create fake objects with final signature). And when I do this > with AbstractQuery, it gives a constructor error. > > How can we solve this? > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/6023#issuecomment-308277435>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakLRaBPp1AfrV_pccrADvYyhGRfnzks5sDxuYgaJpZM4J6aKG> > . >
Author
Owner

@guilherme90 commented on GitHub (Jun 13, 2017):

Okay thanks.

@guilherme90 commented on GitHub (Jun 13, 2017): Okay thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5250