public function UserCancelTest::testUserCancelChangePermission in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Functional/UserCancelTest.php \Drupal\Tests\user\Functional\UserCancelTest::testUserCancelChangePermission()
- 9 core/modules/user/tests/src/Functional/UserCancelTest.php \Drupal\Tests\user\Functional\UserCancelTest::testUserCancelChangePermission()
Tests ability to change the permission for canceling users.
File
- core/
modules/ user/ tests/ src/ Functional/ UserCancelTest.php, line 81
Class
- UserCancelTest
- Ensure that account cancellation methods work as expected.
Namespace
Drupal\Tests\user\FunctionalCode
public function testUserCancelChangePermission() {
\Drupal::service('module_installer')
->install([
'user_form_test',
]);
$this
->config('user.settings')
->set('cancel_method', 'user_cancel_reassign')
->save();
// Create a regular user.
$account = $this
->drupalCreateUser([]);
$admin_user = $this
->drupalCreateUser([
'cancel other accounts',
]);
$this
->drupalLogin($admin_user);
// Delete regular user.
$this
->drupalGet('user_form_test_cancel/' . $account
->id());
$this
->submitForm([], 'Confirm');
// Confirm deletion.
$this
->assertSession()
->pageTextContains("Account {$account->getAccountName()} has been deleted.");
$this
->assertNull(User::load($account
->id()), 'User is not found in the database.');
}