Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

juicymedia's avatar

Laravel Testing Third Party API Responses and Socialite

In my Laravel application, I'm using a third-party API which in order to use, it requires a token generated when logging into the application using OAuth.

For example, when a user signs in using GitLab, they receive a token which is saved in the database. This token is then used to create issues within GitLab.

What is the best way to write feature tests for this logic?

How do I write a test which tests if a user can create an issue with their API token? Specifically testing that if the user has a valid token, when they send a request to the API they receive a "successful" JSON response from the API.

If anyone has any tips or best practice guidelines or articles which help to explain this process, I would much appreciate it.

0 likes
1 reply

Please or to participate in this conversation.