Integration Testing
Understand how to create integration tests in PHP to verify that your application correctly interacts with external services like APIs and databases. Explore handling test infrastructure challenges, such as using sandbox environments and Docker. Gain insights into structuring tests for maintainability and reliability in real-world projects.
We'll cover the following...
Unit tests are good, but they won’t tell us anything if we’re misusing the external services. We have integration tests to check that.
An external service could mean anything outside of our code—an external server providing an API, a database, another application, a command-line tool, or even a different module in our codebase.
How to write integration tests
In general, integration tests follow the same Arrange-Act-Assert structure, but in this case, the Arrange and Assert phases are trickier. We spawn an instance of an external service to call it. So, we often need to arrange the state of an ...