You are here

function Messaging_Methods_Tests::testMessagingMethods in Messaging 5

Same name and namespace in other branches
  1. 6.4 tests/messaging_methods.test \Messaging_Methods_Tests::testMessagingMethods()
  2. 6 tests/messaging_methods.test \Messaging_Methods_Tests::testMessagingMethods()
  3. 6.2 tests/messaging_methods.test \Messaging_Methods_Tests::testMessagingMethods()
  4. 6.3 tests/messaging_methods.test \Messaging_Methods_Tests::testMessagingMethods()
  5. 7 tests/messaging_methods.test \Messaging_Methods_Tests::testMessagingMethods()

Test message sending callbacks for enabled plug-ins

File

tests/messaging_methods.test, line 19

Class

Messaging_Methods_Tests

Code

function testMessagingMethods() {
  $this
    ->messagingStartTest();

  // Start time for message cleanup later
  $start_time = time();

  // Enable debug mode so messages are not actually sent and create user for testing
  $this
    ->drupalModuleEnable('messaging_debug');
  $this
    ->drupalVariableSet('messaging_debug', 0);
  $user = $this
    ->drupalCreateUserRolePerm(array());

  // Try each sending method and retrieve messages from store
  $count = 0;
  foreach (messaging_method_info() as $method => $info) {
    $name = $info['name'];

    // This should create 3 messages for each method
    $message = $this
      ->randomMessage();
    $this
      ->assertEqual(messaging_message_send_user($user, $message, $method, TRUE), TRUE, 'Message sent for user using: ' . $name);
    $this
      ->assertEqual(messaging_message_send(array(
      $user,
      $user,
    ), $message, $method, TRUE), TRUE, 'Bulk messages sent using: ' . $name);
    $queued = messaging_store('get', array(
      'uid' => $user->uid,
      'method' => $method,
    ));
    $this
      ->assertEqual(count($queued), 3, 'The right number of messages have been queued for method: ' . $name . ' (' . count($queued) . ')');
  }
  $this
    ->messagingCleanUp();
}