Unit Testing
Let’s learn how to write unit tests for our application.
We'll cover the following...
Unit tests check single code units (like functions or classes) in isolation. Usually, they are small, fast, and numerous. It’s worth covering every piece of logic in the application with unit tests. If something breaks, a failed unit test will show what exactly is broken.
How to write unit tests
Initial setup
Before running tests locally or in the CI pipeline, we have to install the testing framework. The most common one in PHP is PHPUnit. Please refer to the “Getting Started” guide in the PHPUnit documentation to learn how to install it. It’s not ...