Mercurial > hg > cmmr2012-drupal-site
annotate core/modules/user/tests/src/Kernel/UserSaveTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
rev | line source |
---|---|
Chris@5 | 1 <?php |
Chris@5 | 2 |
Chris@5 | 3 namespace Drupal\Tests\user\Kernel; |
Chris@5 | 4 |
Chris@5 | 5 use Drupal\KernelTests\KernelTestBase; |
Chris@5 | 6 use Drupal\user\Entity\User; |
Chris@5 | 7 |
Chris@5 | 8 /** |
Chris@5 | 9 * Tests account saving for arbitrary new uid. |
Chris@5 | 10 * |
Chris@5 | 11 * @group user |
Chris@5 | 12 */ |
Chris@5 | 13 class UserSaveTest extends KernelTestBase { |
Chris@5 | 14 |
Chris@5 | 15 /** |
Chris@5 | 16 * {@inheritdoc} |
Chris@5 | 17 */ |
Chris@5 | 18 protected static $modules = [ |
Chris@5 | 19 'system', |
Chris@5 | 20 'user', |
Chris@5 | 21 ]; |
Chris@5 | 22 |
Chris@5 | 23 /** |
Chris@5 | 24 * Ensures that an existing password is unset after the user was saved. |
Chris@5 | 25 */ |
Chris@5 | 26 public function testExistingPasswordRemoval() { |
Chris@5 | 27 $this->installSchema('system', ['sequences']); |
Chris@5 | 28 $this->installEntitySchema('user'); |
Chris@5 | 29 |
Chris@5 | 30 /** @var \Drupal\user\Entity\User $user */ |
Chris@5 | 31 $user = User::create(['name' => $this->randomMachineName()]); |
Chris@5 | 32 $user->save(); |
Chris@5 | 33 $user->setExistingPassword('existing password'); |
Chris@5 | 34 $this->assertNotNull($user->pass->existing); |
Chris@5 | 35 $user->save(); |
Chris@5 | 36 $this->assertNull($user->pass->existing); |
Chris@5 | 37 } |
Chris@5 | 38 |
Chris@5 | 39 } |