We would be remiss if we did not mention unit tests in this chapter. Unit testing is a method by which individual units of source code are tested to determine if they are fit for use. Remember from the beginning of the book how we recommended that you write your code in "units"? This is where it all comes together: units of code should be a size that makes them easy to test.
There are a couple of testing frameworks available for PHP that help you write unit tests. It's beyond the scope of this book to demonstrate their use, but we encourage you to look into them if your plugin is getting complicated and difficult to maintain. Unit tests are a real lifesaver because they help you catch any place where your code has failed. All of the tests that we have demonstrated in the book could be easily rewritten as unit tests.
If you want to learn about writing unit tests, we recommend having a look at the SimpleTest library. The code base may have been abandoned, but the site has some good...