public static function call_simpletest(pakeTask $task, $type = 'text', $dirs = array()) { if (!class_exists('TestSuite')) { throw new pakeException('You must install SimpleTest to use this task.'); } SimpleTest::ignore('UnitTestCase'); $base_test_dir = 'test'; $test_dirs = array(); // run tests only in these subdirectories if ($dirs) { foreach ($dirs as $dir) { $test_dirs[] = $base_test_dir . DIRECTORY_SEPARATOR . $dir; } } else { $test_dirs[] = $base_test_dir; } $files = pakeFinder::type('file')->name('*Test.php')->in($test_dirs); if (count($files) == 0) { throw new pakeException('No test to run.'); } $test = new TestSuite('Test suite in (' . implode(', ', $test_dirs) . ')'); foreach ($files as $file) { $test->addFile($file); } ob_start(); if ($type == 'html') { $result = $test->run(new HtmlReporter()); } else { if ($type == 'xml') { $result = $test->run(new XmlReporter()); } else { $result = $test->run(new TextReporter()); } } $content = ob_get_contents(); ob_end_clean(); if ($task->is_verbose()) { echo $content; } }