Skip to content

Instantly share code, notes, and snippets.

Created January 31, 2024 09:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ziadoz/286ea03b156f4c41ea6d1b5225f20a85 to your computer and use it in GitHub Desktop.
Laravel - Modify Route Controller for Testing
namespace Tests;
use App\Controllers\MyController;
use Illuminate\Http\Response;
use Illuminate\Http\Request;
use Tests\TestCase;
class MyTest extends TestCase
public function test_thing(): void
// Make response slower deliberately for testing.
$this->app->bind(MyController::class, function () {
return new class extends MyController
public function index(Request $request): Response
return parent::index($request);
// Test the controller...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment