Late last month, I started talking about writing unit tests in PHPUnit for WordPress-based code. This primarily included the idea of setting up PHPUnit, the setUp function, and writing basic tests.
This did not, however, discuss what I know about the tearDown function which is still an important feature of writing using tests. Further, there’s also two ways to consider writing tests for WordPress projects.
Namely:
- writing tests specifically for plugins and application-layer functionality,
- running unit tests against the WordPress application.
Before moving forward with this particular post, though, I recommend catching up on what I’ve covered thus far. This includes the following posts:
- A WordPress Development Environment (Using a Package Manager)
- An IDE for WordPress Development
- Working with User Settings in Visual Studio Code
- Writing Unit Tests with PHPUnit, Part 1: The Set Up
Once you’ve done that, return to this post and let’s continue discussing the tearDown function and what unit tests in the context of WordPress actually look like.