function PrivatemsgRolesTestCase::testNewUser in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testNewUser()
- 7.2 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testNewUser()
File
- privatemsg_roles/
privatemsg_roles.test, line 266 - 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 roles',
));
$user1 = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
));
// Send a message to the role of user 1.
$this
->drupalLogin($admin);
$edit = array(
'recipient' => user_role_load($user1->roles[4])->name . '[role]',
'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 @role (role).', array(
'@role' => user_role_load($user1->roles[4])->name,
)));
// 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'));
}