public function testHandleError()
 {
     $message = new Message();
     $dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $dispatcher->expects($this->once())->method('dispatch')->will($this->throwException(new \RuntimeException()));
     $backend = new RuntimeBackend($dispatcher);
     $e = false;
     try {
         $backend->handle($message, $dispatcher);
     } catch (HandlingException $e) {
     }
     $this->assertInstanceOf('Sonata\\NotificationBundle\\Exception\\HandlingException', $e);
     $this->assertEquals(MessageInterface::STATE_ERROR, $message->getState());
     $this->assertNotNull($message->getCreatedAt());
     $this->assertNotNull($message->getCompletedAt());
 }
示例#2
0
 /**
  * Constructor.
  *
  * @param EventDispatcherInterface $dispatcher
  * @param bool                     $postponeOnCli Whether to postpone the messages on the CLI, too.
  */
 public function __construct(EventDispatcherInterface $dispatcher, $postponeOnCli = false)
 {
     parent::__construct($dispatcher);
     $this->postponeOnCli = $postponeOnCli;
 }