function PrivatemsgRolesTestCase::testNewUser in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testNewUser()
- 7 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testNewUser()
File
- privatemsg_roles/
privatemsg_roles.test, line 281 - This file contains tests for the privatemsg roles module
Class
- PrivatemsgRolesTestCase
- Test cases for the privatemsg_roles module.
Code
function testNewUser() {
$admin = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
'write privatemsg to all roles',
));
$user1 = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
));
// Send a message to the role of user 1.
$this
->drupalLogin($admin);
$edit = array(
'recipient' => $user1->roles[4] . '[role]',
'subject' => $this
->randomName(10),
'body' => $this
->randomName(50),
);
$this
->drupalPost('messages/new', $edit, t('Send message'));
$this
->assertText(t('A message has been sent to @role (role).', array(
'@role' => $user1->roles[4],
)));
// Add user 2 with the same role now. The user should not see the message.
$user2 = $this
->drupalCreateUser();
// Add role of user 1 to user 2;
$edit_roles = array(
'roles' => $user2->roles + $user1->roles,
);
user_save($user2, $edit_roles);
$this
->drupalLogin($user2);
$this
->drupalGet('messages');
$this
->assertNoText($edit['subject'], t('Newly added user does not see the old message sent to his role'));
}