Nov 25, 2020
0
Level 1
Feature test "No adapter for resource type: "
Hi everybody.
I'm new in L8 and I'm trying to write feature tests for API connection to my model under sanctum middleware.
This is an extract of my routes/api.php:
Route::middleware(['auth:sanctum'])->group(function () {
JsonApi::register('default')->withNamespace('\App\Http\Controllers\Api')->routes(function ($api) {
// it work's
Route::get('timetracks/per-day', 'TimetracksController@perDay')->name('timetracks-per-day');
// it doesn't work
$api->resource('timetracks');
// other routes ...
});
});
This is my test:
public function testTimetrackAccess()
{
$worker = Worker::factory(1)->active()->create()->first();
$response = $this->post(route('api:v1:login'), ['badge' => $worker->badge]);
$response->assertStatus(200);
$response = $this->actingAs($worker)->get(route('api:v1:user'));
$response->assertStatus(200);
$response = $this->actingAs($worker)->get(route('api:v1:timetracks-per-day'));
$response->assertStatus(200);
$response = $this->actingAs($worker)->get(route('api:v1:timetracks.index'));
$response->assertStatus(200);
}
But when I run it, the last assertion fails with this 500 error: "No adapter for resource type: ".
All works fine when I call all routes with Postman.
Is there something wrong or forgotten?
Thank's a lot.
Please or to participate in this conversation.