5

In hopes of getting myself and my coworkers to adopt automated unit testing methods in future projects, I would like to see a proper example on how it's done. Simple introductionary lessons to unit testing only cover very basic examples and they don't seem to convince anyone of the benefits unit testing can offer. What are some open source projects written in PHP that come with an extensive array of unit tests that are done "properly", and can be used as an example of how testing should be done?

2 Answers 2

4

Most PHP frameworks these days are unit tests, for a good example of the difference in tools, Zend Framework uses PHPUnit and CakePHP uses SimpleTest. Their repos should be enough to get you started or writing "proper" unit tests.

3

Drupal, specifically Drupal 7, is probably one of the most high-profile and most comprehensively unit-tested public PHP projects, with built-in unit testing support, over 24,000 tests, and a requirement that all core contributions have tests.

Its unit testing support is based on SimpleTest, and has been in active use for a couple of years now. One of the neat things that Drupal does is test all patches that are attched to issue queues, giving feedback to contributors discussing a particular issue without having to manually apply patches themselves (example).

Not the answer you're looking for? Browse other questions tagged or ask your own question.