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

Hayes's avatar
Level 2

Laravel Unit testing for a package that is based on 3rd party api

This isn't so much as an issue but rather a question/ general opinion.

I have created an open-source package for laravel(https://github.com/webdevhayes/laravel-ticket-tailor-wrapper) which is my first ever open-source package. Now my question is regarding unit testing the API.

1st question. Would I mock up a fake API response/route to test against or would I test against the API key that is present in the env/config file?

2nd question is around Github actions. How would I test aginst the API/ store the API key in Github actions for the tests to run? Does this fall back to my question of creating my own API response/route?

3rd question is if we do test against the API key in GitHub actions how do I store the API key as I clearly don't want to store the key in the repo

Any guidance/advice and opinions would be great, thanks :).

0 likes
0 replies

Please or to participate in this conversation.