Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Created April 4, 2010 13:11
Show Gist options
  • Save wtnabe/355387 to your computer and use it in GitHub Desktop.
Save wtnabe/355387 to your computer and use it in GitHub Desktop.
A Test Suite for SimpleTest 1.0.0 and 'exit status'
<?php
class AllTests extends GroupTest {
function AllTests() {
$this->add( realpath('.') );
}
function add( $dir = null ) {
if ( $dh = opendir( $dir ) ) {
while ( ($e = readdir( $dh )) !== false ) {
$path = $dir.DIRECTORY_SEPARATOR.$e;
if ( is_dir( $path ) and !preg_match( '/\A\./', $e ) ) {
$this->add( $path );
} else if ( preg_match( '/\Atest_.*\.php\z/', $e ) ) {
$this->addTestFile( $path );
}
}
closedir( $dh );
}
}
}
if ( realpath( $_SERVER['SCRIPT_FILENAME'] ) == __FILE__ ) {
$test = &new AllTests();
$reporter = null;
if ( SimpleReporter::inCli() ) {
$reporter =& new TextReporter();
} else {
$reporter = &new HtmlReporter();
}
exit( $test->run( $reporter ) ? 0 : 1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment