You are here

function MessageNotifyNotifierTest::testPostSendMessageSave in Message Notify 7.2

Test Message save on delivery.

File

./message_notify.test, line 81

Class

MessageNotifyNotifierTest
Test the Message notifier plugins handling.

Code

function testPostSendMessageSave() {
  $message = message_create('foo');
  $message->fail = FALSE;
  message_notify_send_message($message, array(), 'test');
  $this
    ->assertTrue($message->mid, 'Message not saved after successful delivery.');
  $message = message_create('foo');
  $message->fail = TRUE;
  message_notify_send_message($message, array(), 'test');
  $this
    ->assertTrue($message->mid, 'Message not saved after unsuccessful delivery.');

  // Disable saving Message on delivery.
  $options = array(
    'save on fail' => FALSE,
    'save on success' => FALSE,
  );
  $message = message_create('foo');
  $message->fail = FALSE;
  message_notify_send_message($message, $options, 'test');
  $this
    ->assertTrue($message->is_new, 'Message not saved after successful delivery.');
  $message = message_create('foo');
  $message->fail = TRUE;
  message_notify_send_message($message, $options, 'test');
  $this
    ->assertTrue($message->is_new, 'Message not saved after unsuccessful delivery.');
}