Skip to content

Instantly share code, notes, and snippets.

@filipfilipovich
Created May 18, 2023 13:42
Show Gist options
  • Save filipfilipovich/395b0d787e2f1397473d23470fb69dd2 to your computer and use it in GitHub Desktop.
Save filipfilipovich/395b0d787e2f1397473d23470fb69dd2 to your computer and use it in GitHub Desktop.
Pest mocking example
<?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