/** * Makes the processChildResult inherited method public. * * @param \PHPUnit_Framework_Test $test * @param \PHPUnit_Framework_TestResult $result * @param string $stdout * @param string $stderr * @return void */ public 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'])) { 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(); $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)) { foreach ($errors as $error) { $result->addError($test, $this->getException($error), $time); } } elseif (!empty($failures)) { foreach ($failures as $failure) { $result->addFailure($test, $this->getException($failure), $time); } } } } $result->endTest($test, $time); }
/** * 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; }
/** * 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; }
/** * 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); }
/** * 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; }
/** * @since Method available since Release 3.5.4 */ protected function handleDependencies() { if (!empty($this->dependencies) && !$this->inIsolation) { $className = get_class($this); $passed = $this->result->passed(); $passedKeys = array_keys($passed); $numKeys = count($passedKeys); for ($i = 0; $i < $numKeys; $i++) { $pos = strpos($passedKeys[$i], ' with data set'); if ($pos !== FALSE) { $passedKeys[$i] = substr($passedKeys[$i], 0, $pos); } } $passedKeys = array_flip(array_unique($passedKeys)); foreach ($this->dependencies as $dependency) { if (strpos($dependency, '::') === FALSE) { $dependency = $className . '::' . $dependency; } if (!isset($passedKeys[$dependency])) { $this->result->addError( $this, new PHPUnit_Framework_SkippedTestError( sprintf( 'This test depends on "%s" to pass.', $dependency ) ), 0 ); return FALSE; } else { if (isset($passed[$dependency])) { $this->dependencyInput[] = $passed[$dependency]; } else { $this->dependencyInput[] = NULL; } } } } return TRUE; }
/** * check current DB checksums (vs initial) * * @todo move to separate class instead of static * * @param PHPUnit_Framework_TestCase $oTest * @param PHPUnit_Framework_TestResult $result */ public static function checkDbChecksums(PHPUnit_Framework_TestCase $oTest = null, PHPUnit_Framework_TestResult $result = null) { $aDiff = array_diff(self::getDbChecksum(), self::_getInitialDbChecksum()); if (count($aDiff) > 0) { if ($oTest && $result) { $result->addError($oTest, new RuntimeException("Changed tables: " . implode(" ", array_keys($aDiff))), 0); } $dbM = new dbMaintenance(); $dbM->restoreDB(MAINTENANCE_WHOLETABLES, MAINTENANCE_MODE_ONLYRESET); echo "|"; } }
/** * 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; }
public function reportAsError($test, PHPUnit_Framework_TestResult $listener) { $listener->addError($test, new PHPUnit_Framework_AssertionFailedError($this->toString()), 0); }
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; } }
function addError(&$test, &$t, $time = 0) { parent::addError($test, $t, $time); echo "E"; }
/** * 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; }
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; }
/** * Adds an error to the list of errors. * * @param \PHPUnit_Framework_Test $test * @param \Exception $e * @param float $time * @return void */ public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) { parent::addError($test, new TestResultException($e), $time); }
/** * 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) { if (!empty($stderr)) { $time = 0; $result->addError($test, new RuntimeException(trim($stderr)), $time); } else { $childResult = @unserialize($stdout); if ($childResult !== FALSE) { if (!empty($childResult['output'])) { print $childResult['output']; } $test->setResult($childResult['testResult']); $test->addToAssertionCount($childResult['numAssertions']); $childResult = $childResult['result']; if ($result->getCollectCodeCoverageInformation()) { $codeCoverageInformation = $childResult->getRawCodeCoverageInformation(); if (isset($codeCoverageInformation[0]) && is_array($codeCoverageInformation[0])) { $result->getCodeCoverage()->append($codeCoverageInformation[0], $test); } } $time = $childResult->time(); $notImplemented = $childResult->notImplemented(); $skipped = $childResult->skipped(); $errors = $childResult->errors(); $failures = $childResult->failures(); if (!empty($notImplemented)) { $result->addError($test, $notImplemented[0]->thrownException(), $time); } else { if (!empty($skipped)) { $result->addError($test, $skipped[0]->thrownException(), $time); } else { if (!empty($errors)) { $result->addError($test, $errors[0]->thrownException(), $time); } else { if (!empty($failures)) { $result->addFailure($test, $failures[0]->thrownException(), $time); } } } } } else { $time = 0; $result->addError($test, new RuntimeException(trim($stdout)), $time); } } $result->endTest($test, $time); }
/** * 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; }
/** * @since Method available since Release 3.5.4 */ protected function handleDependencies() { if (!empty($this->dependencies) && !$this->inIsolation) { $className = get_class($this); $passed = $this->result->passed(); $passedKeys = array_keys($passed); $numKeys = count($passedKeys); for ($i = 0; $i < $numKeys; $i++) { $pos = strpos($passedKeys[$i], ' with data set'); if ($pos !== false) { $passedKeys[$i] = substr($passedKeys[$i], 0, $pos); } } $passedKeys = array_flip(array_unique($passedKeys)); foreach ($this->dependencies as $dependency) { if (strpos($dependency, '::') === false) { $dependency = $className . '::' . $dependency; } if (!isset($passedKeys[$dependency])) { $this->result->addError($this, new PHPUnit_Framework_SkippedTestError(sprintf('This test depends on "%s" to pass.', $dependency)), 0); return false; } if (isset($passed[$dependency])) { if ($passed[$dependency]['size'] > $this->getSize()) { $this->result->addError($this, new PHPUnit_Framework_SkippedTestError('This test depends on a test that is larger than itself.'), 0); return false; } $this->dependencyInput[$dependency] = $passed[$dependency]['result']; } else { $this->dependencyInput[$dependency] = null; } } } return true; }
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { if (!$this->_askForRetry($test, $e, $time)) { parent::addError($test, $e, $time); } }