1 user.test | UserCancelTestCase::testUserCancelWithoutPermission() |
Attempt to cancel account without permission.
File
- core/
modules/ user/ tests/ user.test, line 691 - Tests for user.module.
Class
- UserCancelTestCase
- Test cancelling a user.
Code
function testUserCancelWithoutPermission() {
config_set('system.core', 'user_cancel_method', 'user_cancel_reassign');
// Create a user.
$account = $this->backdropCreateUser(array());
$this->backdropLogin($account);
// Load real user object.
$account = user_load($account->uid, TRUE);
// Create a node.
$node = $this->backdropCreateNode(array('uid' => $account->uid));
// Attempt to cancel account.
$this->backdropGet('user/' . $account->uid . '/edit');
$this->assertNoRaw(t('Cancel account'), 'No cancel account button displayed.');
// Attempt bogus account cancellation request confirmation.
$timestamp = $account->login;
$this->backdropGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid, $account->mail));
$this->assertResponse(403, 'Bogus cancelling request rejected.');
$account = user_load($account->uid);
$this->assertTrue($account->status == 1, 'User account was not canceled.');
// Confirm user's content has not been altered.
$test_node = node_load($node->nid, NULL, TRUE);
$this->assertTrue(($test_node->uid == $account->uid && $test_node->status == 1), 'Node of the user has not been altered.');
}