Mercurial > hg > cmmr2012-drupal-site
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/user/tests/src/Kernel/UserSaveTest.php Thu May 09 15:34:47 2019 +0100 @@ -0,0 +1,39 @@ +<?php + +namespace Drupal\Tests\user\Kernel; + +use Drupal\KernelTests\KernelTestBase; +use Drupal\user\Entity\User; + +/** + * Tests account saving for arbitrary new uid. + * + * @group user + */ +class UserSaveTest extends KernelTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'system', + 'user', + ]; + + /** + * Ensures that an existing password is unset after the user was saved. + */ + public function testExistingPasswordRemoval() { + $this->installSchema('system', ['sequences']); + $this->installEntitySchema('user'); + + /** @var \Drupal\user\Entity\User $user */ + $user = User::create(['name' => $this->randomMachineName()]); + $user->save(); + $user->setExistingPassword('existing password'); + $this->assertNotNull($user->pass->existing); + $user->save(); + $this->assertNull($user->pass->existing); + } + +}