Skip to content
Snippets Groups Projects

Issue #1599286: User cancel confirmation does not work with user cancel action

Open Issue #1599286: User cancel confirmation does not work with user cancel action

Merge request reports

Members who can merge are allowed to add commits.
Ready to merge by members who can write to the target branch.
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
683 $edit = [];
684 $edit['action'] = 'user_cancel_user_action';
685 // Skip cancelling the admin user accounts.
686 for ($i = 2; $i <= 4; $i++) {
687 $edit['user_bulk_form[' . $i . ']'] = TRUE;
688 }
689 $this->drupalGet('admin/people');
690 $this->submitForm($edit, 'Apply');
691
692 $edit = [];
693 // We want to send the user confirmation email to the users.
694 $edit['user_cancel_confirm'] = 1;
695 $edit['user_cancel_method'] = 'user_cancel_delete';
696 $this->submitForm($edit, 'Confirm');
697
698 // Ensure the confirmation email has been sent...
  • quietone
  • 686 for ($i = 2; $i <= 4; $i++) {
    687 $edit['user_bulk_form[' . $i . ']'] = TRUE;
    688 }
    689 $this->drupalGet('admin/people');
    690 $this->submitForm($edit, 'Apply');
    691
    692 $edit = [];
    693 // We want to send the user confirmation email to the users.
    694 $edit['user_cancel_confirm'] = 1;
    695 $edit['user_cancel_method'] = 'user_cancel_delete';
    696 $this->submitForm($edit, 'Confirm');
    697
    698 // Ensure the confirmation email has been sent...
    699 // (Using a more strict assertCount($number_of_users_to_create, $get_all_cancel_confirm_emails($this->container->get('state')))
    700 // kept failing on Drupal CI with 2 !== 3.)
    701 $this->assertGreaterThan(0, $get_all_cancel_confirm_emails($this->container->get('state')), 'All cancelled user accounts got a confirmation e-mail.');
  • quietone
  • 687 $edit['user_bulk_form[' . $i . ']'] = TRUE;
    688 }
    689 $this->drupalGet('admin/people');
    690 $this->submitForm($edit, 'Apply');
    691
    692 $edit = [];
    693 // We want to send the user confirmation email to the users.
    694 $edit['user_cancel_confirm'] = 1;
    695 $edit['user_cancel_method'] = 'user_cancel_delete';
    696 $this->submitForm($edit, 'Confirm');
    697
    698 // Ensure the confirmation email has been sent...
    699 // (Using a more strict assertCount($number_of_users_to_create, $get_all_cancel_confirm_emails($this->container->get('state')))
    700 // kept failing on Drupal CI with 2 !== 3.)
    701 $this->assertGreaterThan(0, $get_all_cancel_confirm_emails($this->container->get('state')), 'All cancelled user accounts got a confirmation e-mail.');
    702 // and accounts are still active.
  • quietone
  • 692 $edit = [];
    693 // We want to send the user confirmation email to the users.
    694 $edit['user_cancel_confirm'] = 1;
    695 $edit['user_cancel_method'] = 'user_cancel_delete';
    696 $this->submitForm($edit, 'Confirm');
    697
    698 // Ensure the confirmation email has been sent...
    699 // (Using a more strict assertCount($number_of_users_to_create, $get_all_cancel_confirm_emails($this->container->get('state')))
    700 // kept failing on Drupal CI with 2 !== 3.)
    701 $this->assertGreaterThan(0, $get_all_cancel_confirm_emails($this->container->get('state')), 'All cancelled user accounts got a confirmation e-mail.');
    702 // and accounts are still active.
    703 foreach (array_keys($users) as $uid) {
    704 /** @var \Drupal\user\UserInterface $user */
    705 $user = $user_storage->loadUnchanged($uid);
    706 $this->assertNotNull($user, 'User account was not deleted.');
    707 $this->assertTrue($user->isActive(), 'User account is still active.');
  • quietone
  • 666 });
    667 };
    668
    669 // Create administrative user.
    670 $admin_user = $this->drupalCreateUser(['administer users']);
    671 $this->drupalLogin($admin_user);
    672
    673 // Create some users.
    674 $users = [];
    675 $number_of_users_to_create = 3;
    676 for ($i = 0; $i < $number_of_users_to_create; $i++) {
    677 $account = $this->drupalCreateUser([]);
    678 $users[$account->id()] = $account;
    679 }
    680
    681 $this->assertCount(0, $get_all_cancel_confirm_emails($this->container->get('state')), 'No cancel confirm email has been sent yet.');
  • quietone
  • 220 220 $admin_form->buildForm($admin_form_mock, $admin_form_state);
    221 221 $admin_form->submitForm($admin_form_mock, $admin_form_state);
    222 222 }
    223 elseif (!$form_state->isValueEmpty('user_cancel_confirm')) {
    224 $cancelled_user = $this->userStorage->load($uid);
    225 // Store cancelling method and whether to notify the user in
    226 // $this->entity for
    227 // \Drupal\user\Controller\UserController::confirmCancel().
    228 $cancelled_user->user_cancel_method = $form_state->getValue('user_cancel_method');
    229 $cancelled_user->user_cancel_notify = $form_state->getValue('user_cancel_notify');
    230 $cancelled_user->save();
    231 _user_mail_notify('cancel_confirm', $cancelled_user);
    232 $this->logger('user')->notice('Sent account cancellation request to %name %email.', ['%name' => $cancelled_user->label(), '%email' => '<' . $cancelled_user->getEmail() . '>']);
    233 }
  • quietone
  • 220 220 $admin_form->buildForm($admin_form_mock, $admin_form_state);
    221 221 $admin_form->submitForm($admin_form_mock, $admin_form_state);
    222 222 }
    223 elseif (!$form_state->isValueEmpty('user_cancel_confirm')) {
    224 $cancelled_user = $this->userStorage->load($uid);
    225 // Store cancelling method and whether to notify the user in
    226 // $this->entity for
    227 // \Drupal\user\Controller\UserController::confirmCancel().
    Please register or sign in to reply
    Loading