November 19, 2014
Trust me, maintaining software is sooo much easier when you have unit tests to let you know when changes meet their goals or introduce new bugs. PHPUnit is the standard suite for testing and analyzing PHP code. But getting PHPUnit working with a WordPress plugin is challenging. This presentation explains the unit tests created for the Login Security Solution plugin. How to mediate the conflict between WordPress’ heavy reliance on globally scoped variables (groan) and PHPUnit’s squashing of global variables
How to test calls to wp_mail(), wp_logout(), wp_redirect()
How to continue execution after PHP produces expected errors
Verifying database inserts that have auto-increment ID’s