Created
May 18, 2023 13:42
-
-
Save filipfilipovich/395b0d787e2f1397473d23470fb69dd2 to your computer and use it in GitHub Desktop.
Pest mocking example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
test('user authorization', function () { | |
$auth = Mockery::mock(Auth::class); | |
$auth->shouldReceive('login'); | |
$auth->shouldReceive('authorize'); | |
$user = new UserRepository($auth); | |
expect($user->getAuthorized()) | |
->not->toBeEmpty(); | |
// Invocations for 'login' and 'authorize' have been mocked, the 'getAuthorized' method should work | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment