Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/tests/src/Functional/UserCancelTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | c2387f117808 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
82 | 82 |
83 // Delete regular user. | 83 // Delete regular user. |
84 $this->drupalPostForm('user_form_test_cancel/' . $account->id(), [], t('Cancel account')); | 84 $this->drupalPostForm('user_form_test_cancel/' . $account->id(), [], t('Cancel account')); |
85 | 85 |
86 // Confirm deletion. | 86 // Confirm deletion. |
87 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), 'User deleted.'); | 87 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.'); |
88 $this->assertFalse(User::load($account->id()), 'User is not found in the database.'); | 88 $this->assertFalse(User::load($account->id()), 'User is not found in the database.'); |
89 } | 89 } |
90 | 90 |
91 /** | 91 /** |
92 * Tests that user account for uid 1 cannot be cancelled. | 92 * Tests that user account for uid 1 cannot be cancelled. |
196 $user_storage->resetCache([$account->id()]); | 196 $user_storage->resetCache([$account->id()]); |
197 $account = $user_storage->load($account->id()); | 197 $account = $user_storage->load($account->id()); |
198 $this->assertTrue($account->isBlocked(), 'User has been blocked.'); | 198 $this->assertTrue($account->isBlocked(), 'User has been blocked.'); |
199 | 199 |
200 // Confirm that the confirmation message made it through to the end user. | 200 // Confirm that the confirmation message made it through to the end user. |
201 $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); | 201 $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user."); |
202 } | 202 } |
203 | 203 |
204 /** | 204 /** |
205 * Disable account and unpublish all content. | 205 * Disable account and unpublish all content. |
206 */ | 206 */ |
253 $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); | 253 $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); |
254 // Confirm that the user was redirected to the front page. | 254 // Confirm that the user was redirected to the front page. |
255 $this->assertSession()->addressEquals(''); | 255 $this->assertSession()->addressEquals(''); |
256 $this->assertSession()->statusCodeEquals(200); | 256 $this->assertSession()->statusCodeEquals(200); |
257 // Confirm that the confirmation message made it through to the end user. | 257 // Confirm that the confirmation message made it through to the end user. |
258 $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); | 258 $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user."); |
259 | 259 |
260 $user_storage->resetCache([$account->id()]); | 260 $user_storage->resetCache([$account->id()]); |
261 $account = $user_storage->load($account->id()); | 261 $account = $user_storage->load($account->id()); |
262 $this->assertTrue($account->isBlocked(), 'User has been blocked.'); | 262 $this->assertTrue($account->isBlocked(), 'User has been blocked.'); |
263 | 263 |
350 $test_comment = $storage->load($comment->id()); | 350 $test_comment = $storage->load($comment->id()); |
351 $this->assertTrue(($test_comment->getOwnerId() == 0 && $test_comment->isPublished()), 'Comment of the user has been attributed to anonymous user.'); | 351 $this->assertTrue(($test_comment->getOwnerId() == 0 && $test_comment->isPublished()), 'Comment of the user has been attributed to anonymous user.'); |
352 $this->assertEqual($test_comment->getAuthorName(), $anonymous_user->getDisplayName(), 'Comment of the user has been attributed to anonymous user name.'); | 352 $this->assertEqual($test_comment->getAuthorName(), $anonymous_user->getDisplayName(), 'Comment of the user has been attributed to anonymous user name.'); |
353 | 353 |
354 // Confirm that the confirmation message made it through to the end user. | 354 // Confirm that the confirmation message made it through to the end user. |
355 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); | 355 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user."); |
356 } | 356 } |
357 | 357 |
358 /** | 358 /** |
359 * Delete account and anonymize all content using a batch process. | 359 * Delete account and anonymize all content using a batch process. |
360 */ | 360 */ |
469 $this->assertTrue($node_storage->load($revision_node->id()), "Current revision of the user's node was not deleted."); | 469 $this->assertTrue($node_storage->load($revision_node->id()), "Current revision of the user's node was not deleted."); |
470 \Drupal::entityManager()->getStorage('comment')->resetCache([$comment->id()]); | 470 \Drupal::entityManager()->getStorage('comment')->resetCache([$comment->id()]); |
471 $this->assertFalse(Comment::load($comment->id()), 'Comment of the user has been deleted.'); | 471 $this->assertFalse(Comment::load($comment->id()), 'Comment of the user has been deleted.'); |
472 | 472 |
473 // Confirm that the confirmation message made it through to the end user. | 473 // Confirm that the confirmation message made it through to the end user. |
474 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); | 474 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user."); |
475 } | 475 } |
476 | 476 |
477 /** | 477 /** |
478 * Create an administrative user and delete another user. | 478 * Create an administrative user and delete another user. |
479 */ | 479 */ |
488 $this->drupalLogin($admin_user); | 488 $this->drupalLogin($admin_user); |
489 | 489 |
490 // Delete regular user. | 490 // Delete regular user. |
491 $this->drupalGet('user/' . $account->id() . '/edit'); | 491 $this->drupalGet('user/' . $account->id() . '/edit'); |
492 $this->drupalPostForm(NULL, NULL, t('Cancel account')); | 492 $this->drupalPostForm(NULL, NULL, t('Cancel account')); |
493 $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getUsername()]), 'Confirmation form to cancel account displayed.'); | 493 $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]), 'Confirmation form to cancel account displayed.'); |
494 $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.'); | 494 $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.'); |
495 | 495 |
496 // Confirm deletion. | 496 // Confirm deletion. |
497 $this->drupalPostForm(NULL, NULL, t('Cancel account')); | 497 $this->drupalPostForm(NULL, NULL, t('Cancel account')); |
498 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), 'User deleted.'); | 498 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.'); |
499 $this->assertFalse(User::load($account->id()), 'User is not found in the database.'); | 499 $this->assertFalse(User::load($account->id()), 'User is not found in the database.'); |
500 } | 500 } |
501 | 501 |
502 /** | 502 /** |
503 * Tests deletion of a user account without an email address. | 503 * Tests deletion of a user account without an email address. |
516 $this->drupalLogin($admin_user); | 516 $this->drupalLogin($admin_user); |
517 | 517 |
518 // Delete regular user without email address. | 518 // Delete regular user without email address. |
519 $this->drupalGet('user/' . $account->id() . '/edit'); | 519 $this->drupalGet('user/' . $account->id() . '/edit'); |
520 $this->drupalPostForm(NULL, NULL, t('Cancel account')); | 520 $this->drupalPostForm(NULL, NULL, t('Cancel account')); |
521 $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getUsername()]), 'Confirmation form to cancel account displayed.'); | 521 $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]), 'Confirmation form to cancel account displayed.'); |
522 $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.'); | 522 $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.'); |
523 | 523 |
524 // Confirm deletion. | 524 // Confirm deletion. |
525 $this->drupalPostForm(NULL, NULL, t('Cancel account')); | 525 $this->drupalPostForm(NULL, NULL, t('Cancel account')); |
526 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), 'User deleted.'); | 526 $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.'); |
527 $this->assertFalse(User::load($account->id()), 'User is not found in the database.'); | 527 $this->assertFalse(User::load($account->id()), 'User is not found in the database.'); |
528 } | 528 } |
529 | 529 |
530 /** | 530 /** |
531 * Create an administrative user and mass-delete other users. | 531 * Create an administrative user and mass-delete other users. |
563 | 563 |
564 // Confirm deletion. | 564 // Confirm deletion. |
565 $this->drupalPostForm(NULL, NULL, t('Cancel accounts')); | 565 $this->drupalPostForm(NULL, NULL, t('Cancel accounts')); |
566 $status = TRUE; | 566 $status = TRUE; |
567 foreach ($users as $account) { | 567 foreach ($users as $account) { |
568 $status = $status && (strpos($this->getTextContent(), $account->getUsername() . ' has been deleted.') !== FALSE); | 568 $status = $status && (strpos($this->getTextContent(), $account->getAccountName() . ' has been deleted.') !== FALSE); |
569 $user_storage->resetCache([$account->id()]); | 569 $user_storage->resetCache([$account->id()]); |
570 $status = $status && !$user_storage->load($account->id()); | 570 $status = $status && !$user_storage->load($account->id()); |
571 } | 571 } |
572 $this->assertTrue($status, 'Users deleted and not found in the database.'); | 572 $this->assertTrue($status, 'Users deleted and not found in the database.'); |
573 | 573 |