Answer the question
In order to leave comments, you need to log in
What is the common way to test JSON API routes (Laravel + PhpUnit) secured with Bearer tokens?
subject
The question is not how to do it at all, but how is it generally accepted and most simply and quickly? How right?
If anyone has a link, I'd appreciate it.
Thank you.
Answer the question
In order to leave comments, you need to log in
Since the tags indicate exactly unit testing, I will mention it first of all.
Almost certainly, routing and authorization were not implemented independently, but by connecting third-party libraries, for good they are already covered by unit tests without your participation, and there is no need to do this again. But what is worth testing in the first place is the integration of these libraries into applications. Which, as it were, hints at integration tests, which I would advise to apply.
Test that routes requiring authorization do not work without it, that the structure of the response is as expected, that invalid arguments will lead to expected errors, etc. etc.
Then you can proceed to testing the scenarios of working with the application themselves.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question