RateLimiting in Tests
Currently, I'm just using a simple request in a for loop to trigger 429.
Is there a "cleaner" way to do the test?
It seems to be a clean way.
I don't think you want to test the middleware itself, you need to make sure some specific routes has that middleware.
collect(Route::getRoutes())
->filter(fn ($route) => str_contains($route->uri(), 'api'))
->each(fn($route) => $this->assertContains('throttle:60,1', $route->gatherMiddleware()));
modify the filter according to your needs
Please or to participate in this conversation.