I'm using Laravel 6.2. I have a named route
Route::get('/dummy/{id}', 'Api\V1\DummyDataController@show')->name('dummy_data_show');
I cannot write the test for it, I get the error Illuminate\Routing\Exceptions\UrlGenerationException: Missing required parameters for [Route: dummy_data_show] [URI: api/v1/dummy/{id}].
These are my attempts (only relevant code):
$request = $this->withHeaders(
[
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$token,
]
)->json('GET',
Route('dummy_data_show'),
[
'id' => 1,
]
);
and also
$request = $this->withHeaders(
[
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$token,
]
)->json('GET',
Route('dummy_data_show'),
1
);
Of course if I try with
$request = $this->withHeaders(
[
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$token,
]
)->json('api/v1/dummy/1');
I don't get the error. What is my error? Thank you!