Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/tests/src/Functional/UserCancelTest.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 4c8ae668cc8c |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
97 public function testUserCancelUid1() { | 97 public function testUserCancelUid1() { |
98 $user_storage = $this->container->get('entity.manager')->getStorage('user'); | 98 $user_storage = $this->container->get('entity.manager')->getStorage('user'); |
99 | 99 |
100 \Drupal::service('module_installer')->install(['views']); | 100 \Drupal::service('module_installer')->install(['views']); |
101 \Drupal::service('router.builder')->rebuild(); | 101 \Drupal::service('router.builder')->rebuild(); |
102 // Update uid 1's name and password to we know it. | |
103 $password = user_password(); | |
104 $account = [ | |
105 'name' => 'user1', | |
106 'pass' => $this->container->get('password')->hash(trim($password)), | |
107 ]; | |
108 // We cannot use $account->save() here, because this would result in the | |
109 // password being hashed again. | |
110 db_update('users_field_data') | |
111 ->fields($account) | |
112 ->condition('uid', 1) | |
113 ->execute(); | |
114 | |
115 // Reload and log in uid 1. | |
116 $user_storage->resetCache([1]); | |
117 $user1 = $user_storage->load(1); | |
118 $user1->pass_raw = $password; | |
119 | 102 |
120 // Try to cancel uid 1's account with a different user. | 103 // Try to cancel uid 1's account with a different user. |
121 $admin_user = $this->drupalCreateUser(['administer users']); | 104 $admin_user = $this->drupalCreateUser(['administer users']); |
122 $this->drupalLogin($admin_user); | 105 $this->drupalLogin($admin_user); |
123 $edit = [ | 106 $edit = [ |
266 $this->drupalPostForm(NULL, NULL, t('Cancel account')); | 249 $this->drupalPostForm(NULL, NULL, t('Cancel account')); |
267 $this->assertText(t('A confirmation request to cancel your account has been sent to your email address.'), 'Account cancellation request mailed message displayed.'); | 250 $this->assertText(t('A confirmation request to cancel your account has been sent to your email address.'), 'Account cancellation request mailed message displayed.'); |
268 | 251 |
269 // Confirm account cancellation request. | 252 // Confirm account cancellation request. |
270 $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. | |
255 $this->assertSession()->addressEquals(''); | |
256 $this->assertSession()->statusCodeEquals(200); | |
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."); | |
259 | |
271 $user_storage->resetCache([$account->id()]); | 260 $user_storage->resetCache([$account->id()]); |
272 $account = $user_storage->load($account->id()); | 261 $account = $user_storage->load($account->id()); |
273 $this->assertTrue($account->isBlocked(), 'User has been blocked.'); | 262 $this->assertTrue($account->isBlocked(), 'User has been blocked.'); |
274 | 263 |
275 // Confirm user's content has been unpublished. | 264 // Confirm user's content has been unpublished. |
281 | 270 |
282 $storage = \Drupal::entityManager()->getStorage('comment'); | 271 $storage = \Drupal::entityManager()->getStorage('comment'); |
283 $storage->resetCache([$comment->id()]); | 272 $storage->resetCache([$comment->id()]); |
284 $comment = $storage->load($comment->id()); | 273 $comment = $storage->load($comment->id()); |
285 $this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.'); | 274 $this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.'); |
286 | |
287 // Confirm that the confirmation message made it through to the end user. | |
288 $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); | |
289 } | 275 } |
290 | 276 |
291 /** | 277 /** |
292 * Delete account and anonymize all content. | 278 * Delete account and anonymize all content. |
293 */ | 279 */ |