public function run($test, $out = null, $clear_globs = true) { $r = parent::run($test, $out, false); /** * Clear test globals if necessary. */ if ($clear_globs) { $test->globs = array(); } return $r; }
public static function testFile($filename, $module_relative = true, $name = null, $package = null, $globs = null, $verbose = null, $report = true, $optionflags = 0, $extraglobs = null, $raise_on_error = false, $parser = null, $encoding = null) { /** * Check for obvious path error. */ if (!is_null($package) && !$module_relative) { throw new UnexpectedValueException('Package may only be specified for module-relative paths.'); } /** * Initialize parser. */ if (is_null($parser)) { $parser = new DocTest_Parser(); } /** * Relativize the path */ list($text, $filename) = self::_loadTestFile($filename, $package, $module_relative); /** * If no name was given, then use the file's name. */ if (is_null($name)) { $name = basename($filename); } /** * Assemble the globals. */ if (is_null($globs)) { $globs = array(); } if (!is_null($extraglobs)) { $globs = array_merge($globs, $extraglobs); } if ($raise_on_error) { $runner = new DocTest_DebugRunner(null, $verbose, $optionflags); } else { $runner = new DocTest_Runner(null, $verbose, $optionflags); } /** * Convert encoding * * @todo Make this work. */ if (!is_null($encoding) && function_exists('mb_convert_encoding')) { $text = mb_convert_encoding($text, $encoding); } /** * Read the file, convert it to a test, and run it. */ $test = $parser->getDocTest($text, $globs, $name, $filename, 0); $runner->run($test); if ($report) { $runner->summarize(); } return new DocTest_TestResults($runner->failures, $runner->tries); }