You are here

function PrivatemsgRolesTestCase::testSendMessagetoRoleAPI in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testSendMessagetoRoleAPI()
  2. 7 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testSendMessagetoRoleAPI()

File

privatemsg_roles/privatemsg_roles.test, line 24
This file contains tests for the privatemsg roles module

Class

PrivatemsgRolesTestCase
Test cases for the privatemsg_roles module.

Code

function testSendMessagetoRoleAPI() {
  $admin = $this
    ->drupalCreateUser(array(
    'read privatemsg',
    'write privatemsg',
    'write privatemsg to all roles',
  ));
  $user1 = $this
    ->drupalCreateUser(array(
    'read privatemsg',
    'write privatemsg',
  ));
  $user2 = $this
    ->drupalCreateUser();

  // Add role of user 1 to user 2;
  $edit = array(
    'roles' => $user2->roles + $user1->roles,
  );
  user_save($user2, $edit);
  $recipient = user_role_load($user1->roles[4]);
  $recipient->recipient = $recipient->rid;
  $recipient->type = 'role';
  privatemsg_new_thread(array(
    $recipient,
  ), $subject = $this
    ->randomName(10), $body = $this
    ->randomName(50), array(
    'author' => $admin,
  ));
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('messages');
  $this
    ->assertRaw($subject . '</a> <span class="marker">new</span>', t('Message is displayed as new'));
  $this
    ->clickLink($subject);
  $this
    ->assertText($body, t('Thread starter body displayed.'));
}