You have until August 8, 2008 to move away fromPHP4.
We already use PHPUnit and PHPT at Digg, but this DBUnit thingy has me interested.
What should you test?
Backend: business logic, data access layers, reusable component/libraries, etc.
Frontend: form processing, templates, rich interfaces (AJAX/JSON), feed, web services, etc.
Use browser based testing (Selenium / Watir) for interfaces in your acceptance tests.
Use unit tests (PHPUnit or PHPT) for parseable results / libraries.
Developer tests are tests that developers make to ensure the code works as designed. Acceptance tess are tests that someone makes to ensure it works as the client expects it to.
Requirements for proper testing include a reusable test environment, automatic execution of test code, easy to learn/use, etc.
Unit tests: PHPUnit, SimpleTest
System tests: Selenium (PHPUnit + Selenium RC), Watir
Non-Functional tests: ab, httperf, JMeter, Grinder, OpenSTA, etc.
Security: Chorizo.
PHPUnit_Extensions_Database_TestCase is a port of the DBUnit extension for JUnit to PHPUnit.
Used for DB driven projects
Puts your DB into a known state between test runs.
Avoids problems with one test corrupting the database for other tests.
Has the ability to export and import your database to and from XML datasets.
You can use tableEquals() to compare a table created / modified by a test to either an array of expected records, an XML file or another control table. Hot.
It outputs diff’s between the two tables for inspection. Hot.
Avoid testing against MySQL (use SQLite) to avoid using up server resources, inter-process communication, etc. Make sure your SQL is compatible with SQLite. Tests are much faster when ran against SQLite.
Tests that only test one thing are more informative that tests where failure can come from many sources.