SimpleTest

SimpleTest is a PHP unit testing and web testing framework. The complete API documentation is available at http://simpletest.org/api/. If you are using Eclipse, a SimpleTest plugin is also provided on this site. SimpleTest has been integrated into Elgg 1.7 and onwards, Moodle, and Drupal.

Installing SimpleTest
Simply download the latest stable release. Unzip it into your working directory
$ tar xzvf simpletest_1.0.1.tar.gz

SimpleTest Example

require_once('simpletest/autorun.php');

class MyExample extends UnitTestCase {   
    function myex() {
        $var2 = array();        
        $this->assertTrue(is_array($var2));    
    }
}

output

OK?
Test cases run: 0/1, Passes: 0, Failures: 0, Exceptions: 0

This example also involves inserting testing code into the original code. In reality, unit tests are written in separate files and these files are not ported into production environments.