In the past posts in this series, I’ve covered the following two topics:
- Writing Unit Tests with PHPUnit, Part 1: The Set-Up. A guide to getting started with writing PHPUnit tests through the use of a basic cache and using the setUp method of the framework.
- Writing Unit Tests with PHPUnit, Part 2: The Tear Down. A tutorial on how to write unit tests that properly leverage the setUp and tearDown methods of PHPUnit.
Each of the above is meant to provide a primer for how to get started with writing very basic unit tests. Things can get more complex especially as an application or project grows (but that’s always true, right?).
But to make sure one is prepared for that, there’s one final component to unit testing that I believe we should focus on and that’s understanding the PHPUnit XML Configuration File (which you may have seen in other projects as phpunit.xml).
PHPUnit XML Configuration
So in this post, I’m going to setup a simple project that uses PHPUnit, writes a few tests like the ones we’ve already seen, and leverages a configuration file to automate testing.
Furthermore, I’m going to do what I can to best explain the necessary parts of the configuration file so you can include one in your next project.
Further, it gives you something to build upon as your testing chops grow stronger.
Is There More? (Always, Right?)
Finally, if you’re eager to really dive into the configuration file, you can read the manual’s in-depth explanation of it.
Note, however, everything that’s outlined above aims to be what you need to get started with setting up your own PHPUnit XML Configuration file.