Skip to content

Commit

Permalink
VSF2-54 - throws error on no token found, adjusts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MacBalc committed Jun 16, 2023
1 parent 0188289 commit 7ce67f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/shop/account/resetting_password.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Feature: Resetting one customer password
And I prepare check reset password token operation for invalid token
And I send that GraphQL request
Then I should receive a JSON response
And This response should contain pattern '/^\{"data":\{"password_reset_tokenUser":null\}\}$/'
And This response should contain pattern '/"data":\{"password_reset_tokenUser":null\}/'
3 changes: 2 additions & 1 deletion spec/Resolver/Query/PasswordResetTokenResolverSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function it_should_return_null_on_invalid_token(

$userRepository->findOneBy(['passwordResetToken' => $token])->willReturn(null);

$this->__invoke(null, $context)->shouldReturn(null);
$this->shouldThrow(\RuntimeException::class)
->during('__invoke', [null, $context]);
}
}
4 changes: 2 additions & 2 deletions src/Resolver/Query/PasswordResetTokenResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(UserRepositoryInterface $userRepository)
$this->userRepository = $userRepository;
}

public function __invoke($item, array $context): ?ShopUserInterface
public function __invoke($item, array $context): ShopUserInterface
{
$token = $context['args']['passwordResetToken'];
/** @var ?ShopUserInterface $user */
Expand All @@ -34,6 +34,6 @@ public function __invoke($item, array $context): ?ShopUserInterface
return $user;
}

return null;
throw new \RuntimeException('Token not found');
}
}

0 comments on commit 7ce67f7

Please sign in to comment.