Level 104
Your authentication token is in the query string, right, so the Request header does not make sense in your test. It should be sufficient to make the test request with a valid token in the query string.
1 like
I have an api that not use authentication of laravel but I use custom guard
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
/**
* Register any application authentication / authorization services.
*/
public function boot(): void
{
Auth::viaRequest('custom-token', function (Request $request) {
return User::where('token', (string) $request->token)->first();
});
}
How can I use Laravel testing to test my api, I have tried withHeader with Authentication but it not works
Please or to participate in this conversation.