Loading core/modules/user/src/Entity/User.php +1 −0 Original line number Diff line number Diff line Loading @@ -398,6 +398,7 @@ public function setUsername($username) { */ public function setExistingPassword($password) { $this->get('pass')->existing = $password; return $this; } /** Loading core/modules/user/tests/src/Kernel/UserEntityTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,16 @@ public function testUserValidation() { $this->assertFalse((bool) $violations->count()); } /** * Tests that ::existingPassword can be used for chaining. */ public function testChainExistingPasswordMethod() { /** @var \Drupal\user\Entity\User $user */ $user = User::create([ 'name' => $this->randomMachineName(), ]); $user = $user->setExistingPassword('existing_pass'); $this->assertInstanceOf(User::class, $user); } } Loading
core/modules/user/src/Entity/User.php +1 −0 Original line number Diff line number Diff line Loading @@ -398,6 +398,7 @@ public function setUsername($username) { */ public function setExistingPassword($password) { $this->get('pass')->existing = $password; return $this; } /** Loading
core/modules/user/tests/src/Kernel/UserEntityTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,16 @@ public function testUserValidation() { $this->assertFalse((bool) $violations->count()); } /** * Tests that ::existingPassword can be used for chaining. */ public function testChainExistingPasswordMethod() { /** @var \Drupal\user\Entity\User $user */ $user = User::create([ 'name' => $this->randomMachineName(), ]); $user = $user->setExistingPassword('existing_pass'); $this->assertInstanceOf(User::class, $user); } }