Search code examples
symfonydoctrinephpspec

how to spec createQueryBuilder() in controller


I'm writing phpspec test for controller In action I am calling another method with this:

$this->getDoctrine()->getManager()->createQueryBuilder();

I cannot pass this in phpspec. What I'm getting is

method Double\ObjectManager\P7::createQueryBuilder() is not defined

Have you got any suggestion how to spec it?


Solution

  • If you can't spec something, it's a indicator you have a bad design. In your case you should never create query builders in your controllers. Controller should be only a clue between different services.

    For doctrine queries create repositories!