function PrivatemsgRolesTestCase::testPermission in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testPermission()
- 7 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testPermission()
File
- privatemsg_roles/
privatemsg_roles.test, line 138 - This file contains tests for the privatemsg roles module
Class
- PrivatemsgRolesTestCase
- Test cases for the privatemsg_roles module.
Code
function testPermission() {
$user1 = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
));
// Update permissions.
$this
->checkPermissions(array(), TRUE);
// Give permission to write only a specific role.
$user2 = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
'write privatemsg to role ' . $user1->roles[3],
));
$this
->drupalLogin($user2);
// Send a message to the role of user 1 and 2.
$edit = array(
'recipient' => $user1->roles[DRUPAL_AUTHENTICATED_RID] . '[role]',
'subject' => $this
->randomName(10),
'body' => $this
->randomName(50),
);
$this
->drupalGet('messages/new');
// Verify that both recipient type descriptions show up.
$this
->assertText(t('Enter the name of a role to write a message to all users which have that role.'));
$this
->assertText(t('Enter a user name to write a message to a user.'));
$this
->drupalPost(NULL, $edit, t('Send message'));
$this
->assertText(t('You must include at least one valid recipient.'));
}