api.php
Route::middleware(['trim.strings', 'other'])->group(function () {
Route::put('a', 'a@put');
})
Kernel.php
use App\Http\Middleware\TrimStrings;
protected $routeMiddleware = [
'trim.strings' => TrimStrings::class,
'other' => Other::class
]
Tests.php
$this->withMiddleware()
->putJson('/a', '{"a": [{"name" => "hi "}]')
->assertStatus(200)
->assertJson([
'data' => [
'a' => [
['name' => "hi"],
]
]
]);
More Info:
- Laravel 7
Behavior:
- In the tests:
- Only middlewares
other
is called
- Only middlewares
- Normal call:
- Middlewares
other
andtrim.strings
are used
- Middlewares
Question: Why is the string trimmer never called inside tests ?
Aucun commentaire:
Enregistrer un commentaire