/** * @param Prophet $container mock of Symfony\Component\DependencyInjection\ContainerInterface * @param Prophet $doctrine mock of Doctrine\Bundle\DoctrineBundle\Registry * @param Prophet $manager mock of Doctrine\Common\Persistence\ObjectManager * @param Prophet $templating mock of Symfony\Component\Templating\EngineInterface * @param Prophet $repository mock of Doctrine\ORM\EntityRepository */ function described_with($container, $doctrine, $manager, $templating, $repository) { if (!$this->object->getProphetSubject() instanceof ContainerAwareInterface) { throw new \RuntimeException('Controller must implement ContainerAwareInterface.'); } $container->get('doctrine')->willReturn($doctrine); $container->get('templating')->willReturn($templating); $doctrine->getManager()->willReturn($manager); $manager->getRepository()->willReturn($repository); $repository->findAll()->willReturn(array()); $expectation = $templating->renderResponse()->willReturn(new Response()); $this->object->setContainer($container); $this->object->getProphetMatchers()->add(new TemplateRenderMatcher($expectation)); $this->controller = $this->object; }
/** * @param Prophet $subject mock of stdClass */ function it_can_specify_a_method_during_which_an_exception_should_be_throw($subject) { $subject->someMethod()->willThrow('\\Exception'); $this->positiveMatch('throw', $subject, array('\\Exception'))->duringSomeMethod(array()); }