Testing is an essential aspect of developing in any programming language. If you don't test your source code then how can you verify it works as expected? Manual testing can only be performed irregularly and usually only in limited ways. The answer to testing source code regularly, and in depth, is to write automated tests which can be frequently executed. In PHP such tests are usually written using a unit testing framework, a framework which allows the source code of any application or library to be tested as isolated units of functionality such as a single class or method. As unit testing has gained popularity, it has become a standard practice in PHP with libraries and frameworks such as Swiftmailer, the Zend Framework and Symfony all requiring unit test coverage of their source code.

Unit Testing is often seen as an arcane, time consuming task - which it sometimes can be! But the point of spending time writing tests is to improve the quality of your source code so it has fewer overall bugs, many of which are detected early, a continual testing process to prevent new changes from changing the behaviour of older code, and to provide confidence that your code can be depended on. There are other benefits too, and we'll detail these later.
The Testing Fallacies

Unit Testing, and actually all other forms of testing, fall afoul of four common excuses which hinder adoption by developers.

1. It's time consuming and takes too long.
2. Complex code cannot be tested.
3. So long as it works, I don't need to write tests.
4. Testing is boring.

These are testing fallacies, excuses which appear quite reasonable but are actually misinformed in subtle ways. So let's clear up a few things!