Skip to content

Instantly share code, notes, and snippets.

View kenan-recebli's full-sized avatar

Kənan Rəcəbli kenan-recebli

View GitHub Profile
@lukeraymonddowning
lukeraymonddowning / example.php
Created August 20, 2024 12:12
Shows how to mock actions easily for testing in Laravel
public function shouldHaveReceivedAction(string $action)
{
$original = $this->app->make($action);
$this->mock($original)
->shouldReceive('handle')
->atLeast()->once()
->andReturnUsing(fn (...$args) => $original->handle(...$args));
}