How test all routs to ensure they return at least a none-500 response?
I want to be sure that all GET routes defined in routes.php file return a 200 response and all non-get routes return at least a non-500 http response. How can I do that using phpunit and Laravel testing facilities?
@usman Thanks for your reply. I look for a way to test all routes without writing a test for each route manually. I currently use the following code but I'm looking for a better one.
public function testExample()
{
$routeCollection = \Illuminate\Support\Facades\Route::getRoutes();
foreach ($routeCollection as $value) {
$response = $this->call($value->getMethods()[0], $value->getPath());
$this->assertNotEquals(500, $response->status(),"{$value->getMethods()[0]} {$value->getPath()}");
}
}