3 require_once unittest
::tap_path();
6 * Wrapper around the tapunit wrapper around phptap
8 class Ninja_Unit_Test
{
9 function __construct() {
10 $paths = array('test/unit_test');
12 $main_tap = new phptap("Ninja unit test suite");
14 $argv = isset($argv) ?
$argv : $GLOBALS['argv'];
15 $argc = isset($argc) ?
$argc : $GLOBALS['argc'];
17 for ($i = 1; $i < $argc; $i++
) {
20 $files[] = $argv[$i +
1];
25 foreach ($paths as $path) {
26 foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator
::KEY_AS_PATHNAME
)) as $path => $file) {
27 // Skip files without "_Test" suffix
28 if ( ! $file->isFile() OR substr($path, -9) !== '_Test'.EXT
)
31 // The class name should be the same as the file name
32 $class = substr($path, strrpos($path, '/') +
1, -(strlen(EXT
)));
35 if (substr($class, 0, 1) === '.')
38 // skip unless defined specific one on cli
39 if(count($files) > 0 and !in_array($class, $files))
42 // Check for duplicate test class name
43 if (class_exists($class, FALSE))
44 $main_tap->fail("Duplicate test class: $class in $path");
46 // Include the test class
48 runUnit($class, $main_tap);
52 $exit_code = $main_tap->done(false);
53 exit((int)($exit_code > 1));