Skip to content

Commit

Permalink
test(feature): add test for updating password of the user
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Dec 3, 2023
1 parent 43ec495 commit 6b730c3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions t/Feature/Resource/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,33 @@ public function testDefaultUpdate()
"secret" => $user_data["email"]
]);
}

public function testPasswordUpdate()
{
$authenticated_info = $this->makeAuthenticatedInfo();

$faker = Factory::create();
$original_new_password = $faker->password();
$password_data = [
"old_password" => $authenticated_info->getPassword(),
"new_password" => $original_new_password,
"confirm_new_password" => $original_new_password
];

$result = $authenticated_info
->getRequest()
->withBodyFormat("json")
->patch("/api/v1/user/password", [
"user" => $password_data
]);

$result->assertStatus(204);
$users = model(setting("Auth.userProvider"));
$found_user = $users->findByCredentials([
"email" => $authenticated_info->getUser()->email,
"password" => $original_new_password
]);
$this->assertNotNull($found_user);
$this->assertSame($found_user->id, $authenticated_info->getUser()->id);
}
}

0 comments on commit 6b730c3

Please sign in to comment.