Issue #3137119 by munish.kumar, johnwebdev, Jaypan, jungle, xjm, catch: User::setExistingPassword() does not return $this for chaining

merge-requests/2501/head
Alex Pott 2022-07-09 15:17:23 +01:00
parent 436f58744e
commit 51e7a08352
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
2 changed files with 13 additions and 0 deletions

View File

@ -398,6 +398,7 @@ class User extends ContentEntityBase implements UserInterface {
*/
public function setExistingPassword($password) {
$this->get('pass')->existing = $password;
return $this;
}
/**

View File

@ -91,4 +91,16 @@ class UserEntityTest extends KernelTestBase {
$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);
}
}