For our automated tests, we use PHPUnit (currently version 3.2.11). You can find good documentation on PHPUnit here. We have created some base classes to help use PHPUnit in TopazPort.

Assuming you have the TopazPort SVN project on your machine, you already have PHPUnit (you are welcome to also install it through PEAR, but on some systems that's not possible).

  1. If you did not install PHPUnit through the PEAR installer, go into the tests-php5/PHPUnit directory and edit the pear-phpunit.bat file appropriately as instructed by the installing-phpunit.txt file. You will want to rename pear-phpunit.bat to phpunit.bat and edit it. You can put the directory it is in on your path, or just remember to reference the directory it is in when you use it.
  2. Create a test database. The PHPUnit tests need a scratch database that will be emptied and filled as needed. You need to create one. I like using testdb as my database, username and password (easy to remember!).
  3. Create your dbinit.php file. The test code needs access to that test database. In tests-php5 is the file dbinit.blank.php. Copy that file to dbinit.php and edit it as necessary for your test database.

 Now you should be set to start testing.

We keep our configuration files in the tests-php5/configs directory. You can look there for samples.

The testDbHelper class provides a way of importing SQL data files into your test database.

TopazPort_TestCase provides a base class that can initialize the database for you with the current structure. I would expect most tests to extend this class (or one of the others below).

TopazPort_Objekts_TestCase provides a base class that has some functions for testing our Objekts.