Created
August 20, 2024 12:12
-
-
Save lukeraymonddowning/62d8dec74bdee4b888f2342feb96cc63 to your computer and use it in GitHub Desktop.
Shows how to mock actions easily for testing in Laravel
This file contains hidden or 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
public function shouldHaveReceivedAction(string $action) | |
{ | |
$original = $this->app->make($action); | |
$this->mock($original) | |
->shouldReceive('handle') | |
->atLeast()->once() | |
->andReturnUsing(fn (...$args) => $original->handle(...$args)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment