本文整理汇总了PHP中PHPUnit_Framework_TestResult::endTest方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestResult::endTest方法的具体用法?PHP PHPUnit_Framework_TestResult::endTest怎么用?PHP PHPUnit_Framework_TestResult::endTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestResult
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestResult::endTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run(PHPUnit_Framework_TestResult $result = null)
{
PHPUnit_Framework_Assert::resetCount();
if ($result === NULL) {
$result = new PHPUnit_Framework_TestResult();
}
$this->suite->publishTestArticles();
// Add articles needed by the tests.
$backend = new ParserTestSuiteBackend();
$result->startTest($this);
// Support the transition to PHPUnit 3.5 where PHPUnit_Util_Timer is replaced with PHP_Timer
if (class_exists('PHP_Timer')) {
PHP_Timer::start();
} else {
PHPUnit_Util_Timer::start();
}
$r = false;
try {
# Run the test.
# On failure, the subclassed backend will throw an exception with
# the details.
$pt = new PHPUnitParserTest();
$r = $pt->runTest($this->test['test'], $this->test['input'], $this->test['result'], $this->test['options'], $this->test['config']);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
// PHPUnit_Util_Timer -> PHP_Timer support (see above)
if (class_exists('PHP_Timer')) {
$result->addFailure($this, $e, PHP_Timer::stop());
} else {
$result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
}
} catch (Exception $e) {
// PHPUnit_Util_Timer -> PHP_Timer support (see above)
if (class_exists('PHP_Timer')) {
$result->addFailure($this, $e, PHP_Timer::stop());
} else {
$result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
}
}
// PHPUnit_Util_Timer -> PHP_Timer support (see above)
if (class_exists('PHP_Timer')) {
$result->endTest($this, PHP_Timer::stop());
} else {
$result->endTest($this, PHPUnit_Util_Timer::stop());
}
$backend->recorder->record($this->test['test'], $r);
$this->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
return $result;
}
示例2: run
public function run(PHPUnit_Framework_TestResult $result = null)
{
$result->startTest($this);
$this->testCase->runBare();
$this->testCase->runBare();
$result->endTest($this, 0);
}
示例3: run
public function run(\PHPUnit_Framework_TestResult $result = null)
{
if (!$result) {
$result = new \PHPUnit_Framework_TestResult();
}
$reader = new \Fulfil\Test\SpecTest\Reader();
$tests = $reader->read($testFile);
foreach ($tests as $test) {
foreach ($test->data as $case) {
\PHP_Timer::start();
$result->startTest($this);
try {
$ctx = new \Fulfil\Context();
$test->test->apply($case->in, $ctx);
$flat = $ctx->flatten();
} catch (\Exception $ex) {
// yum
}
$time = \PHP_Timer::stop();
try {
\PHPUnit_Framework_Assert::assertEquals($case->valid, $flat->valid);
} catch (\PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e, $time);
}
$result->endTest($this, $time);
}
}
return $result;
}
示例4: run
public function run(\PHPUnit_Framework_TestResult $result = null)
{
if (!$result) {
$result = new \PHPUnit_Framework_TestResult();
}
$opt = null;
\PHP_Timer::start();
$result->startTest($this);
try {
$opt = \Docopt::handle($this->doc, array('argv' => $this->argv, 'exit' => false));
} catch (\Exception $ex) {
// gulp
}
$found = null;
if ($opt) {
if (!$opt->success) {
$found = array('user-error');
} elseif (empty($opt->args)) {
$found = array();
} else {
$found = $opt->args;
}
}
$time = \PHP_Timer::stop();
try {
\PHPUnit_Framework_Assert::assertEquals($this->expect, $found);
} catch (\PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e, $time);
}
$result->endTest($this, $time);
return $result;
}
示例5: endTest
/**
* (non-PHPdoc)
* @see PHPUnit_Framework_TestResult::endTest()
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
{
$result = parent::endTest($test, $time);
if (!$this->lastTestFailed && $test instanceof PHPUnit_Framework_TestCase) {
$class = get_class($test);
$trimmedTestName = $test->getName();
$teseName = $test->getName();
$trimmedTestName = KalturaTestCaseBase::trimTestInstanceName($teseName);
$this->passed[$class . '::' . $trimmedTestName] = $test->getResult();
$this->time += $time;
}
return $result;
}
示例6: run
/**
* Runs a test and collects its result in a TestResult instance.
*
* @param PHPUnit_Framework_TestResult $result
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result = null)
{
$sections = $this->parse();
$code = $this->render($sections['FILE']);
if ($result === null) {
$result = new PHPUnit_Framework_TestResult();
}
$php = PHPUnit_Util_PHP::factory();
$skip = false;
$time = 0;
$settings = $this->settings;
$result->startTest($this);
if (isset($sections['INI'])) {
$settings = array_merge($settings, $this->parseIniSection($sections['INI']));
}
if (isset($sections['SKIPIF'])) {
$jobResult = $php->runJob($sections['SKIPIF'], $settings);
if (!strncasecmp('skip', ltrim($jobResult['stdout']), 4)) {
if (preg_match('/^\\s*skip\\s*(.+)\\s*/i', $jobResult['stdout'], $message)) {
$message = substr($message[1], 2);
} else {
$message = '';
}
$result->addFailure($this, new PHPUnit_Framework_SkippedTestError($message), 0);
$skip = true;
}
}
if (!$skip) {
PHP_Timer::start();
$jobResult = $php->runJob($code, $settings);
$time = PHP_Timer::stop();
if (isset($sections['EXPECT'])) {
$assertion = 'assertEquals';
$expected = $sections['EXPECT'];
} else {
$assertion = 'assertStringMatchesFormat';
$expected = $sections['EXPECTF'];
}
$output = preg_replace('/\\r\\n/', "\n", trim($jobResult['stdout']));
$expected = preg_replace('/\\r\\n/', "\n", trim($expected));
try {
PHPUnit_Framework_Assert::$assertion($expected, $output);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e, $time);
} catch (Throwable $t) {
$result->addError($this, $t, $time);
} catch (Exception $e) {
$result->addError($this, $e, $time);
}
}
$result->endTest($this, $time);
return $result;
}
示例7: processChildResult
/**
* Processes the TestResult object from an isolated process.
*
* @param PHPUnit_Framework_TestCase $test
* @param PHPUnit_Framework_TestResult $result
* @param string $stdout
* @param string $stderr
* @since Method available since Release 3.5.0
*/
protected function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
{
$time = 0;
if (!empty($stderr)) {
$result->addError($test, new PHPUnit_Framework_Exception(trim($stderr)), $time);
} else {
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
});
try {
$childResult = unserialize($stdout);
restore_error_handler();
} catch (ErrorException $e) {
restore_error_handler();
$childResult = FALSE;
$result->addError($test, new PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time);
}
if ($childResult !== FALSE) {
if (!empty($childResult['output'])) {
print $childResult['output'];
}
$test->setResult($childResult['testResult']);
$test->addToAssertionCount($childResult['numAssertions']);
$childResult = $childResult['result'];
if ($result->getCollectCodeCoverageInformation()) {
$result->getCodeCoverage()->merge($childResult->getCodeCoverage());
}
$time = $childResult->time();
$notImplemented = $childResult->notImplemented();
$skipped = $childResult->skipped();
$errors = $childResult->errors();
$failures = $childResult->failures();
if (!empty($notImplemented)) {
$result->addError($test, $this->getException($notImplemented[0]), $time);
} else {
if (!empty($skipped)) {
$result->addError($test, $this->getException($skipped[0]), $time);
} else {
if (!empty($errors)) {
$result->addError($test, $this->getException($errors[0]), $time);
} else {
if (!empty($failures)) {
$result->addFailure($test, $this->getException($failures[0]), $time);
}
}
}
}
}
}
$result->endTest($test, $time);
}
示例8: processChildResult
/**
* Processes the TestResult object from an isolated process.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_TestResult $result
* @param string $stdout
* @param string $stderr
* @since Method available since Release 3.5.0
*/
private function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
{
$time = 0;
if (!empty($stderr)) {
$result->addError($test, new PHPUnit_Framework_Exception(trim($stderr)), $time);
} else {
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
});
try {
if (strpos($stdout, "#!/usr/bin/env php\n") === 0) {
$stdout = substr($stdout, 19);
}
$childResult = unserialize(str_replace("#!/usr/bin/env php\n", '', $stdout));
restore_error_handler();
} catch (ErrorException $e) {
restore_error_handler();
$childResult = false;
$result->addError($test, new PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time);
}
if ($childResult !== false) {
if (!empty($childResult['output'])) {
$output = $childResult['output'];
}
$test->setResult($childResult['testResult']);
$test->addToAssertionCount($childResult['numAssertions']);
$childResult = $childResult['result'];
if ($result->getCollectCodeCoverageInformation()) {
$result->getCodeCoverage()->merge($childResult->getCodeCoverage());
}
$time = $childResult->time();
$notImplemented = $childResult->notImplemented();
$risky = $childResult->risky();
$skipped = $childResult->skipped();
$errors = $childResult->errors();
$failures = $childResult->failures();
if (!empty($notImplemented)) {
$result->addError($test, $this->getException($notImplemented[0]), $time);
} elseif (!empty($risky)) {
$result->addError($test, $this->getException($risky[0]), $time);
} elseif (!empty($skipped)) {
$result->addError($test, $this->getException($skipped[0]), $time);
} elseif (!empty($errors)) {
$result->addError($test, $this->getException($errors[0]), $time);
} elseif (!empty($failures)) {
$result->addFailure($test, $this->getException($failures[0]), $time);
}
}
}
$result->endTest($test, $time);
if (!empty($output)) {
print $output;
}
}
示例9: doRun
/**
* Run the test
*
* @param \PHPUnit_Framework_TestResult $result
* @param Zept $zept
* @return \PHPUnit_Framework_TestResult
*/
private function doRun(\PHPUnit_Framework_TestResult $result, Zept $zept)
{
$time = 0;
\PHP_Timer::start();
try {
$jobResult = $this->codeRunner->run($zept->getZephirCode(), $zept->getPhpCode(), $this->silent);
$time = \PHP_Timer::stop();
$assertion = $zept->getAssertion();
\PHPUnit_Framework_Assert::$assertion($this->cleanString($zept->getExpected()), $this->cleanString($jobResult['stdout']));
} catch (\Exception $exception) {
$result->addError($this, $exception, $time);
} catch (\Throwable $throwable) {
$result->addError($this, $throwable, $time);
}
$result->endTest($this, $time);
$result->flushListeners();
return $result;
}
示例10: run
/**
* Runs a test and collects its result in a TestResult instance.
*
* @param PHPUnit_Framework_TestResult $result
* @param array $options Array with ini settings for the php instance run,
* key being the name if the setting, value the ini value.
* @return PHPUnit_Framework_TestResult
* @access public
*/
public function run(PHPUnit_Framework_TestResult $result = NULL, $options = array())
{
if (!class_exists('PEAR_RunTest', FALSE)) {
throw new RuntimeException('Class PEAR_RunTest not found.');
}
if ($result === NULL) {
$result = new PHPUnit_Framework_TestResult();
}
if (!is_array($options)) {
throw new InvalidArgumentException();
}
$options = array_merge($options, $this->options);
$coverage = $result->getCollectCodeCoverageInformation();
if ($coverage) {
$options = array('coverage' => TRUE);
} else {
$options = array();
}
$runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options);
if ($coverage) {
$runner->xdebug_loaded = TRUE;
} else {
$runner->xdebug_loaded = FALSE;
}
$result->startTest($this);
PHPUnit_Util_Timer::start();
$buffer = $runner->run($this->filename, $options);
$time = PHPUnit_Util_Timer::stop();
$base = basename($this->filename);
$path = dirname($this->filename);
$coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
$diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
$expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
$logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
$outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
$phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
if (is_object($buffer) && $buffer instanceof PEAR_Error) {
$result->addError($this, new RuntimeException($buffer->getMessage()), $time);
} else {
if ($buffer == 'SKIPPED') {
$result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0);
} else {
if ($buffer != 'PASSED') {
$result->addFailure($this, PHPUnit_Framework_ComparisonFailure::diffEqual(file_get_contents($expFile), file_get_contents($outFile), FALSE, $this->getName()), $time);
}
}
}
foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
if (file_exists($file)) {
unlink($file);
}
}
if ($coverage) {
eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
unset($coverageData[$phpFile]);
$codeCoverageInformation = array('test' => $this, 'files' => $coverageData);
$result->appendCodeCoverageInformation($this, $codeCoverageInformation);
unlink($coverageFile);
}
$result->endTest($this, $time);
return $result;
}
示例11: run
public function run(PHPUnit_Framework_TestResult $result = NULL)
{
if ($result === NULL) {
$result = new PHPUnit_Framework_TestResult();
$result->startTest($this);
$counter = 0;
foreach ($this->queries as $query_data) {
$query = 'EXPLAIN ' . $query_data['query'];
$parameters = $query_data['parameters'];
$parameters_print = '';
try {
if (!empty($parameters)) {
$res = Dal::query($query, $parameters);
$parameters_print = 'PARAMETERS:' . "\n";
foreach ($parameters as $param) {
$parameters_print .= '- ' . $param . "\n";
}
} else {
$res = Dal::query($query);
}
} catch (PAException $e) {
try {
PHPUnit_Framework_Assert::assertEquals($e->getCode(), DB_QUERY_FAILED);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e);
} catch (Exception $e) {
$result->addError($this, $e);
}
}
$tables = array();
print "{{{ ==================================================================\n";
$query_row = wordwrap($explain . "QUERY: \"{$query}\"", 70);
print $query_row . "\n";
if (!empty($parameters_print)) {
print "----------------------------------------------------------------------\n";
print $parameters_print;
}
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
print "----------------------------------------------------------------------\n";
print 'ID: ' . $row->id . "\n";
print 'SELECT TYPE: ' . $row->select_type . "\n";
print 'TABLE: ' . $row->table . "\n";
if (!empty($row->table)) {
$tables[] = $row->table;
}
print 'TYPE: ' . $row->type . "\n";
print 'POSSIBLE KEYS: ' . $row->possible_keys . "\n";
print 'KEY: ' . $row->key . "\n";
print 'KEY LENGTH: ' . $row->key_len . "\n";
print 'REFERENCE: ' . $row->ref . "\n";
print 'ROWS: ' . $row->rows . "\n";
print 'EXTRA: ' . $row->Extra . "\n";
$counter++;
}
// Now show all the tables used in the query.
foreach ($tables as $table) {
print "----------------------------------------------------------------------\n";
try {
$create_table = Dal::query_one("SHOW CREATE TABLE {$table}");
} catch (PAException $e) {
if ($e->getCode() != DB_QUERY_FAILED) {
throw $e;
}
$bits = preg_split("/(\\s+|,)/", $query);
$pos = array_search($table, $bits);
if ($pos === NULL) {
throw new PAException(GENERAL_SOME_ERROR, "Failed to find real name for table {$table} in query {$sql}");
}
$table = strtolower($bits[$pos - 1]) == 'as' ? $bits[$pos - 2] : $bits[$pos - 1];
$create_table = Dal::query_one("SHOW CREATE TABLE {$table}");
}
echo $create_table[1] . "\n";
}
print "================================================================== }}}\n";
}
$result->endTest($this);
return $result;
}
}
示例12: run
/**
* Runs a test and collects its result in a TestResult instance.
*
* @param PHPUnit_Framework_TestResult $result
*
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result = null)
{
$sections = $this->parse();
$code = $this->render($sections['FILE']);
if ($result === null) {
$result = new PHPUnit_Framework_TestResult();
}
$skip = false;
$xfail = false;
$time = 0;
$settings = $this->settings;
$result->startTest($this);
if (isset($sections['INI'])) {
$settings = array_merge($settings, $this->parseIniSection($sections['INI']));
}
if (isset($sections['ENV'])) {
$env = $this->parseEnvSection($sections['ENV']);
$this->phpUtil->setEnv($env);
}
// Redirects STDERR to STDOUT
$this->phpUtil->setUseStderrRedirection(true);
if ($result->enforcesTimeLimit()) {
$this->phpUtil->setTimeout($result->getTimeoutForLargeTests());
}
if (isset($sections['SKIPIF'])) {
$jobResult = $this->phpUtil->runJob($sections['SKIPIF'], $settings);
if (!strncasecmp('skip', ltrim($jobResult['stdout']), 4)) {
if (preg_match('/^\\s*skip\\s*(.+)\\s*/i', $jobResult['stdout'], $message)) {
$message = substr($message[1], 2);
} else {
$message = '';
}
$result->addFailure($this, new PHPUnit_Framework_SkippedTestError($message), 0);
$skip = true;
}
}
if (isset($sections['XFAIL'])) {
$xfail = trim($sections['XFAIL']);
}
if (!$skip) {
if (isset($sections['STDIN'])) {
$this->phpUtil->setStdin($sections['STDIN']);
}
if (isset($sections['ARGS'])) {
$this->phpUtil->setArgs($sections['ARGS']);
}
PHP_Timer::start();
$jobResult = $this->phpUtil->runJob($code, $settings);
$time = PHP_Timer::stop();
try {
$this->assertPhptExpectation($sections, $jobResult['stdout']);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
if ($xfail !== false) {
$result->addFailure($this, new PHPUnit_Framework_IncompleteTestError($xfail, 0, $e), $time);
} else {
$result->addFailure($this, $e, $time);
}
} catch (Throwable $t) {
$result->addError($this, $t, $time);
}
if ($result->allCompletelyImplemented() && $xfail !== false) {
$result->addFailure($this, new PHPUnit_Framework_IncompleteTestError('XFAIL section but test passes'), $time);
}
$this->phpUtil->setStdin('');
$this->phpUtil->setArgs('');
if (isset($sections['CLEAN'])) {
$cleanCode = $this->render($sections['CLEAN']);
$this->phpUtil->runJob($cleanCode, $this->settings);
}
}
$result->endTest($this, $time);
return $result;
}
示例13: run
public function run(PHPUnit_Framework_TestResult $result = NULL)
{
PHPUnit_Framework_Assert::resetCount();
if ($result === NULL) {
$result = new PHPUnit_Framework_TestResult();
}
$t = MediaWikiParserTestSuite::$iter->current();
$k = MediaWikiParserTestSuite::$iter->key();
if (!MediaWikiParserTestSuite::$iter->valid()) {
return;
}
// The only way this should happen is if the parserTest.txt
// file were modified while the script is running.
if ($k != $this->number) {
$i = $this->number;
wfDie("I got confused!\n");
}
$result->startTest($this);
PHPUnit_Util_Timer::start();
$r = false;
try {
$r = MediaWikiParserTestSuite::$parser->runTest($t['test'], $t['input'], $t['result'], $t['options'], $t['config']);
PHPUnit_Framework_Assert::assertTrue(true, $t['test']);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
} catch (Exception $e) {
$result->addError($this, $e, PHPUnit_Util_Timer::stop());
}
PHPUnit_Framework_Assert::assertTrue(true, $t['test']);
$result->endTest($this, PHPUnit_Util_Timer::stop());
MediaWikiParserTestSuite::$parser->recorder->record($t['test'], $r);
MediaWikiParserTestSuite::$iter->next();
$this->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
return $result;
}
示例14: run
/**
* Runs a test and collects its result in a TestResult instance.
*
* @param PHPUnit_Framework_TestResult $result
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result = null)
{
$sections = $this->parse();
$code = $this->render($sections['FILE']);
if ($result === null) {
$result = new PHPUnit_Framework_TestResult();
}
$skip = false;
$time = 0;
$settings = $this->settings;
$result->startTest($this);
if (isset($sections['INI'])) {
$settings = array_merge($settings, $this->parseIniSection($sections['INI']));
}
// Redirects STDERR to STDOUT
$this->phpUtil->setUseStderrRedirection(true);
if (isset($sections['SKIPIF'])) {
$jobResult = $this->phpUtil->runJob($sections['SKIPIF'], $settings);
if (!strncasecmp('skip', ltrim($jobResult['stdout']), 4)) {
if (preg_match('/^\\s*skip\\s*(.+)\\s*/i', $jobResult['stdout'], $message)) {
$message = substr($message[1], 2);
} else {
$message = '';
}
$result->addFailure($this, new PHPUnit_Framework_SkippedTestError($message), 0);
$skip = true;
}
}
if (!$skip) {
PHP_Timer::start();
$jobResult = $this->phpUtil->runJob($code, $settings);
$time = PHP_Timer::stop();
try {
$this->assertPhptExpectation($sections, $jobResult['stdout']);
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$result->addFailure($this, $e, $time);
} catch (Throwable $t) {
$result->addError($this, $t, $time);
} catch (Exception $e) {
$result->addError($this, $e, $time);
}
if (isset($sections['CLEAN'])) {
$cleanCode = $this->render($sections['CLEAN']);
$this->phpUtil->runJob($cleanCode, $this->settings);
}
}
$result->endTest($this, $time);
return $result;
}
示例15: run
/**
* Runs a test and collects its result in a TestResult instance.
*
* @param PHPUnit_Framework_TestResult $result
* @param array $options
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array())
{
if (!class_exists('PEAR_RunTest', FALSE)) {
throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.');
}
if (isset($GLOBALS['_PEAR_destructor_object_list']) && is_array($GLOBALS['_PEAR_destructor_object_list']) && !empty($GLOBALS['_PEAR_destructor_object_list'])) {
$pearDestructorObjectListCount = count($GLOBALS['_PEAR_destructor_object_list']);
} else {
$pearDestructorObjectListCount = 0;
}
if ($result === NULL) {
$result = new PHPUnit_Framework_TestResult();
}
$coverage = $result->getCollectCodeCoverageInformation();
$options = array_merge($options, $this->options);
if (!isset($options['include_path'])) {
$options['include_path'] = get_include_path();
}
if ($coverage) {
$options['coverage'] = TRUE;
} else {
$options['coverage'] = FALSE;
}
$currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE);
$runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options);
if ($coverage) {
$runner->xdebug_loaded = TRUE;
} else {
$runner->xdebug_loaded = FALSE;
}
$result->startTest($this);
PHP_Timer::start();
$buffer = $runner->run($this->filename, $options);
$time = PHP_Timer::stop();
error_reporting($currentErrorReporting);
$base = basename($this->filename);
$path = dirname($this->filename);
$coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
$diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
$expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
$logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
$outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
$phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
if (is_object($buffer) && $buffer instanceof PEAR_Error) {
$result->addError($this, new PHPUnit_Framework_Exception($buffer->getMessage()), $time);
} else {
if ($buffer == 'SKIPPED') {
$result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0);
} else {
if ($buffer != 'PASSED') {
$expContent = file_get_contents($expFile);
$outContent = file_get_contents($outFile);
$result->addFailure($this, new PHPUnit_Framework_ComparisonFailure($expContent, $outContent, $expContent, $outContent), $time);
}
}
}
foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
if (file_exists($file)) {
unlink($file);
}
}
if ($coverage && file_exists($coverageFile)) {
eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
unset($coverageData[$phpFile]);
$result->getCodeCoverage()->append($coverageData, $this);
unlink($coverageFile);
}
$result->endTest($this, $time);
// Do not invoke PEAR's destructor mechanism for PHP 4
// as it raises an E_STRICT.
if ($pearDestructorObjectListCount == 0) {
unset($GLOBALS['_PEAR_destructor_object_list']);
} else {
$count = count($GLOBALS['_PEAR_destructor_object_list']) - $pearDestructorObjectListCount;
for ($i = 0; $i < $count; $i++) {
array_pop($GLOBALS['_PEAR_destructor_object_list']);
}
}
return $result;
}