/** * @expectedException \Sonata\NotificationBundle\Exception\InvalidParameterException */ public function testInvalidType() { $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface'); $message = new Message(); $message->setBody(array('level' => 'ERROR', 'message' => 'Alert - Area 52 get compromised!!')); $event = new ConsumerEvent($message); $consumer = new LoggerConsumer($logger); $consumer->process($event); }
public function testClone() { $originalMessage = new Message(); $originalMessage->setId(42); $originalMessage->setBody('body'); $originalMessage->setState(MessageInterface::STATE_ERROR); $clonedMessage = clone $originalMessage; $this->assertEquals('body', $clonedMessage->getBody()); $this->assertEquals(MessageInterface::STATE_ERROR, $clonedMessage->getState()); $this->assertNull($clonedMessage->getId()); }
public function testStatuses() { $message = new Message(); $message->setState(MessageInterface::STATE_IN_PROGRESS); $this->assertTrue($message->isRunning()); $message->setState(MessageInterface::STATE_CANCELLED); $this->assertTrue($message->isCancelled()); $message->setState(MessageInterface::STATE_ERROR); $this->assertTrue($message->isError()); $message->setState(MessageInterface::STATE_OPEN); $this->assertTrue($message->isOpen()); }
/** * @return \Sonata\NotificationBundle\Tests\Entity\Message */ protected function getMessage($state = MessageInterface::STATE_OPEN) { $message = new Message(); $message->setState($state); return $message; }