Skip to content

Commit

Permalink
Tests: Simplify route definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbearman committed Feb 15, 2024
1 parent 8a71360 commit 6e9a35e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class Customer extends Model

Create a route for your model.
```php
Route::get('/customer/{customer}', function (Customer $customer) {
return $customer;
});
Route::get('/customer/{customer}', fn (Customer $customer) => $customer);
```

```php
Expand Down
50 changes: 23 additions & 27 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,36 @@ protected function getPackageProviders($app): array

protected function defineRoutes($router): void
{
$router->get('/calamari/{calamari}', function (Calamari $calamari) {
return $calamari;
})->middleware(SubstituteBindings::class);
$router->get('/calamari/{calamari}', fn (Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class);

$router->get('/calamari/{calamari}/children/{child}', function (Calamari $calamari, Calamari $child) {
return $child;
})->scopeBindings()->middleware(SubstituteBindings::class);
$router->get('/calamari/{calamari}/children/{child}', fn (Calamari $calamari, Calamari $child) => $child)
->middleware(SubstituteBindings::class)
->scopeBindings();

$router->get('/deleted/calamari/{calamari}', function (Calamari $calamari) {
return $calamari;
})->withTrashed()->middleware(SubstituteBindings::class);
$router->get('/deleted/calamari/{calamari}', fn (Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class)
->withTrashed();

$router->get('/squad/{squad}', function (Squad $squad) {
return $squad;
})->middleware(SubstituteBindings::class);
$router->get('/squad/{squad}', fn (Squad $squad) => $squad)
->middleware(SubstituteBindings::class);

$router->get('/squad/{squad}/calamari/{calamari}', function (Squad $squad, Calamari $calamari) {
return $calamari;
})->scopeBindings()->middleware(SubstituteBindings::class);
$router->get('/squad/{squad}/calamari/{calamari}', fn (Squad $squad, Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class)
->scopeBindings();

$router->get('/ocean/{ocean}/calamari/{calamari}', function (Ocean $ocean, Calamari $calamari) {
return $calamari;
})->scopeBindings()->middleware(SubstituteBindings::class);
$router->get('/ocean/{ocean}/calamari/{calamari}', fn (Ocean $ocean, Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class)
->scopeBindings();

$router->get('/admin/calamari/{calamari:id}', function (Calamari $calamari) {
return $calamari;
})->middleware(SubstituteBindings::class);
$router->get('/admin/calamari/{calamari:id}', fn (Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class);

$router->get('/admin/squad/{squad}/calamari/{calamari:id}', function (Squad $squad, Calamari $calamari) {
return $calamari;
})->scopeBindings()->middleware(SubstituteBindings::class);
$router->get('/admin/squad/{squad}/calamari/{calamari:id}', fn (Squad $squad, Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class)
->scopeBindings();

$router->get('/escargot/{calamari:slug}', function (Calamari $calamari) {
return $calamari;
})->middleware(SubstituteBindings::class);
$router->get('/escargot/{calamari:slug}', fn (Calamari $calamari) => $calamari)
->middleware(SubstituteBindings::class);
}
}

0 comments on commit 6e9a35e

Please sign in to comment.