You are here

function PrivatemsgGroupsTestCase::testNewUser in Privatemsg 7.2

Test to make sure newly added group member doesn't see old messages.

File

privatemsg_groups/privatemsg_groups.test, line 321
This file contains tests for the privatemsg groups module

Class

PrivatemsgGroupsTestCase
Test cases for the privatemsg_groups module.

Code

function testNewUser() {

  // Send a message to the group of user 1.
  $this
    ->drupalLogin($this->group1_manager);
  $edit = array(
    'recipient' => $this->group1->title . '[group]',
    'subject' => $this
      ->randomName(10),
    'body[value]' => $this
      ->randomName(50),
  );
  $this
    ->drupalPost('messages/new', $edit, t('Send message'));
  $this
    ->assertText(t('A message has been sent to @group (group).', array(
    '@group' => $this->group1->title,
  )));

  // Add user 2 to the same group now. The user should not see the message.
  $user2 = $this
    ->drupalCreateUser(array(
    'read privatemsg',
    'write privatemsg',
  ));
  og_group('node', $this->group1->nid, array(
    'entity' => $user2->uid,
  ));
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('messages');
  $this
    ->assertNoText($edit['subject'], t('Newly added user does not see the old message sent to his group'));
}