The plugin, that I am writing in php, is getting data from an external api. I have gathered some sample-data which the api sends (array). Now I would like to create tests to make sure that the plugin is working properly when the main software is updated. But it is not possible to make testing queries in production software to an external api. How can I then use the gathered data for testing my software? Are there any patterns or tutorials, best practices? (In some places the api query is in the middle of method/function?)
You need to mock the request to the API.
Here is a PHP example: https://github.com/InterNations/http-mock/blob/master/doc/start.md
What this example does, is start a small fake http server, which always returns that data that you expect/need for the test.
You can also start a seperate mock-server manually and use that to test against. Read more at http://www.mock-server.com/