Show your test with the mock as well :)
Aug 20, 2022
14
Level 7
How to mock a function dependencies
How can I mock the dependencies of this function ?
public function login(string $email, string $password, string $ipAddress): array
{
$login = $this->client->login(null, [
'applicationId' => config("fusionauth.appid", "..."),
'ipAddress' => $ipAddress,
'loginId' => $email,
'password' => $password
]);
if(!$login->wasSuccessful()) {
return ['result' => $login->errorResponse, 'success' => false, 'status' => $login->status];
}
return ['result' => $login->successResponse, 'success' => true, 'status' => $login->status];
}
I wanna mock the auth client but it's giving me this error:
Error: Call to undefined method stdClass::wasSuccessful()
Level 102
@stderr33 awesome. Please either show the solution and mark that as the best answer or pick one from the thread. This will set the thread as solved
1 like
Please or to participate in this conversation.