/** * Constructor- defines an output mode * @param $outmode a string of the final output mode **/ public function __construct($outmode, $test_count) { $st = new Snap_Tester($outmode, $test_count); $this->reporter = $st->getOutput(); $this->report_list = array(); $this->case_list = array(); }
$test = $options['test']; $klass = $options['klass']; // decrypt if required if (SNAP_WI_CRYPT) { $file = snap_decrypt($file, SNAP_WI_CRYPT); } // ensure file path matches test path prefix $file = str_replace(array('..', '//'), array('.', '/'), $file); if (!is_file($file)) { echo ''; exit; } if (strpos($file, SNAP_WI_TEST_PATH) !== 0 || !preg_match('#' . SNAP_WI_TEST_MATCH . '#', $file)) { echo ''; exit; } // file is safe, check test and klass if (!$test || !$klass) { echo ''; exit; } // now, test // new reporter in phpserializer mode $snap = new Snap_Tester('json'); // include the file, so that all base components are there require_once $file; // add the class now that it exists $snap->addInput('local', $klass); // run tests with an exact match on the test name $snap->runTests('^' . $test . '$'); exit;
$path = realpath($path); // analyze subprocess if ($analyze) { writelog('Doing analyze substep'); $analyzer = new Snap_FileAnalyzer(); $results = $analyzer->analyzeFile($path); echo SNAPTEST_TOKEN_START; echo serialize($results); echo SNAPTEST_TOKEN_END; echo SNAP_STREAM_ENDING_TOKEN; exit; } // test subprocess if ($test) { // new reporter in phpserializer mode $snap = new Snap_Tester('phpserializer'); // unencode $test = Snap_Request::decodeTestKey($test); // include the file, so that all base components are there require_once $test['file']; // add the class now that it exists $snap->addInput('local', $test['class']); writelog('Doing test substep: ' . $test['class'] . '::' . $test['method']); // run tests with an exact match on the test name $snap->runTests('^' . $test['method'] . '$'); echo SNAP_STREAM_ENDING_TOKEN; exit; } // generate list of files to test if (is_dir($path)) { $file_list = SNAP_recurse_directory($path, $xtn);