/**
  * Test send notices.
  *
  * @dataProvider getNotices
  *
  * @param \PHPUnit_Framework_MockObject_MockObject $event
  * @param array $params
  * @param string $method
  * @param string $type
  */
 public function testSendNotices(\PHPUnit_Framework_MockObject_MockObject $event, array $params, $method, $type)
 {
     $that = $this;
     $this->templating->expects($this->once())->method('render')->will($this->returnCallback(function ($received_tpl, $received_params) use($that, $type, $params) {
         $that->assertEquals('AnimeDbCatalogBundle:Notice:messages/' . $type . '.html.twig', $received_tpl);
         $that->assertEquals($params, $received_params);
         return 'foo';
     }));
     $this->em->expects($this->once())->method('persist')->will($this->returnCallback(function ($notice) use($that, $type) {
         /* @var $notice \AnimeDb\Bundle\AppBundle\Entity\Notice */
         $that->assertInstanceOf('\\AnimeDb\\Bundle\\AppBundle\\Entity\\Notice', $notice);
         $that->assertEquals($type, $notice->getType());
         $that->assertEquals('foo', $notice->getMessage());
     }));
     call_user_func([$this->listener, $method], $event);
 }
Example #2
0
 protected function mockTwigEngine()
 {
     $this->twigEngine = $this->getMockBuilder('Symfony\\Bundle\\TwigBundle\\TwigEngine')->disableOriginalConstructor()->getMock();
     $this->twigEngine->expects($this->any())->method('exists')->will($this->returnValue(true));
     return $this->twigEngine;
 }