function PrivatemsgRolesTestCase::testDeleteUser in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg_roles/privatemsg_roles.test \PrivatemsgRolesTestCase::testDeleteUser()
Verify that deleting a user does not leave stale data behind.
File
- privatemsg_roles/
privatemsg_roles.test, line 310 - This file contains tests for the privatemsg roles module
Class
- PrivatemsgRolesTestCase
- Test cases for the privatemsg_roles module.
Code
function testDeleteUser() {
$admin = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
'write privatemsg to all roles',
));
$user = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
));
// Send a message to the role of user 1.
$this
->drupalLogin($admin);
$edit = array(
'recipient' => $user->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' => $user->roles[4],
)));
$this
->drupalLogin($user);
$this
->drupalGet('messages');
$this
->assertText($edit['subject'], t('Message sent to role is visible.'));
// Delete user and make sure that no recipient entries of him are left in
// table.
user_delete(array(), $user->uid);
$this
->assertFalse(db_result(db_query_range("SELECT 1 FROM {pm_index} WHERE recipient = %d AND type IN ('user', 'hidden')", $user->uid, 0, 1)));
}