Verified Commit 6764848b authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3137119 by munish.kumar, johnwebdev, Jaypan, jungle, xjm, catch:...

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

(cherry picked from commit 51e7a083)
parent de637ade
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@ public function setUsername($username) {
   */
  public function setExistingPassword($password) {
    $this->get('pass')->existing = $password;
    return $this;
  }

  /**
+12 −0
Original line number Diff line number Diff line
@@ -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);
  }

}