本文整理汇总了PHP中PHPUnit_Framework_TestResult::errorCount方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestResult::errorCount方法的具体用法?PHP PHPUnit_Framework_TestResult::errorCount怎么用?PHP PHPUnit_Framework_TestResult::errorCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestResult
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestResult::errorCount方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: paintFooter
/**
* Renders the summary of test passes and failures.
*
* @param PHPUnit_Framework_TestResult $result Result object
*
* @return void
*/
public function paintFooter($result)
{
ob_end_flush();
echo '</ul>';
if ($result->failureCount() + $result->errorCount() > 0) {
echo '<div class="alert-box alert radius">';
} else {
echo '<div class="alert-box success radius">';
}
echo $result->count() - $result->skippedCount() . ' of ';
echo $result->count() . ' test methods complete: ';
echo count($result->passed()) . ' passes, ';
echo $result->failureCount() . ' fails, ';
echo $this->numAssertions . ' assertions and ';
echo $result->errorCount() . ' exceptions.';
echo '</div>';
echo '<p><strong>Time:</strong> ' . __('%0.5f seconds', $result->time()) . '</p>';
echo '<p><strong>Peak Memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>';
$this->_paintLinks();
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverage();
if (method_exists($coverage, 'getSummary')) {
$report = $coverage->getSummary();
$this->paintCoverage($report);
}
if (method_exists($coverage, 'getData')) {
$report = $coverage->getData();
$this->paintCoverage($report);
}
}
$this->paintDocumentEnd();
}
示例2: paintFooter
/**
* Paints the end of the test with a summary of
* the passes and failures.
*
* @param PHPUnit_Framework_TestResult $result Result object
*
* @return void
*/
public function paintFooter($result)
{
ob_end_flush();
$colour = $result->failureCount() + $result->errorCount() > 0 ? "red" : "green";
echo "</ul>\n";
echo "<div style=\"";
echo "padding: 8px; margin: 1em 0; background-color: {$colour}; color: white;";
echo "\">";
echo $result->count() - $result->skippedCount() . "/" . $result->count();
echo " test methods complete:\n";
echo "<strong>" . count($result->passed()) . "</strong> passes, ";
echo "<strong>" . $result->failureCount() . "</strong> fails, ";
echo "<strong>" . $this->numAssertions . "</strong> assertions and ";
echo "<strong>" . $result->errorCount() . "</strong> exceptions.";
echo "</div>\n";
echo '<div style="padding:0 0 5px;">';
echo '<p><strong>Time:</strong> ' . $result->time() . ' seconds</p>';
echo '<p><strong>Peak memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>';
echo $this->_paintLinks();
echo '</div>';
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverage();
if (method_exists($coverage, 'getSummary')) {
$report = $coverage->getSummary();
echo $this->paintCoverage($report);
}
if (method_exists($coverage, 'getData')) {
$report = $coverage->getData();
echo $this->paintCoverage($report);
}
}
$this->paintDocumentEnd();
}
示例3: paintFooter
/**
* Paints the end of the test with a summary of
* the passes and failures.
*
* @param PHPUnit_Framework_TestResult $result Result object
* @return void
*/
public function paintFooter($result)
{
if ($result->failureCount() + $result->errorCount() == 0) {
echo "\nOK\n";
} else {
echo "FAILURES!!!\n";
}
echo "Test cases run: " . $result->count() . "/" . ($result->count() - $result->skippedCount()) . ', Passes: ' . $this->numAssertions . ', Failures: ' . $result->failureCount() . ', Exceptions: ' . $result->errorCount() . "\n";
echo 'Time: ' . $result->time() . " seconds\n";
echo 'Peak memory: ' . number_format(memory_get_peak_usage()) . " bytes\n";
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverageInformation();
echo $this->paintCoverage($coverage);
}
}
示例4: printResult
/**
* @param \PHPUnit_Framework_TestResult $result
*/
public function printResult(\PHPUnit_Framework_TestResult $result)
{
if (!$this->silent) {
$this->printHeader($result->time());
if ($result->errorCount() > 0) {
$this->printErrors($result);
}
if ($result->failureCount() > 0) {
if ($result->errorCount() > 0) {
print "\n--\n\n";
}
$this->printFailures($result);
}
if ($result->notImplementedCount() > 0) {
if ($result->failureCount() > 0) {
print "\n--\n\n";
}
$this->printIncompletes($result);
}
if ($result->skippedCount() > 0) {
if ($result->notImplementedCount() > 0) {
print "\n--\n\n";
}
$this->printSkipped($result);
}
}
$this->printFooter($result);
}
示例5: assertTestsAreSuccessful
protected function assertTestsAreSuccessful(PHPUnit_Framework_TestResult $result)
{
if ($result->wasSuccessful()) {
return;
}
$msg = "Test should pass, instead there are {$result->errorCount()} errors:\n";
/** @var $error PHPUnit_Framework_TestFailure */
foreach ($result->errors() as $error) {
$msg .= $error->exceptionMessage();
}
$this->fail($msg);
}
示例6: printErrors
/**
* @param PHPUnit_Framework_TestResult $result
*/
protected function printErrors(PHPUnit_Framework_TestResult $result)
{
$this->printDefects($result->errors(), $result->errorCount(), 'error');
}
示例7: printFooter
/**
* Prints final results when all tests ended.
*
* PHPUnit_TextUI_ResultPrinter compatible
*
* @return void
*/
public function printFooter(\PHPUnit_Framework_TestResult $result)
{
$testCount = $result->count();
$assertionCount = $this->numAssertions;
$failureCount = $result->failureCount();
$errorCount = $result->errorCount();
$incompleteCount = $result->notImplementedCount();
$skipCount = $result->skippedCount();
$riskyCount = $result->riskyCount();
$resultStatus = $errorCount + $failureCount ? 'KO' : 'OK';
$resultMessage = sprintf('Results %s. ', $resultStatus) . $this->formatCounters($testCount, $assertionCount, $failureCount, $errorCount, $incompleteCount, $skipCount, $riskyCount);
$context = array('operation' => __FUNCTION__, 'status' => $resultStatus, 'testCount' => $testCount, 'assertionCount' => $assertionCount, 'failureCount' => $failureCount, 'errorCount' => $errorCount, 'incompleteCount' => $incompleteCount, 'skipCount' => $skipCount, 'riskyCount' => $riskyCount);
$this->logger->notice($resultMessage, $context);
}
示例8: renderTestStatistics
/**
* Renders and output the tests statistics.
*
* @param PHPUnit_Framework_TestResult $testResult the test result
*
* @return void
*/
protected function renderTestStatistics(PHPUnit_Framework_TestResult $testResult)
{
if ($testResult->wasSuccessful()) {
$testStatistics = '<h2 class="wasSuccessful">' . $this->translate('testing_success') . '</h2>';
} else {
if ($testResult->errorCount() > 0) {
$testStatistics = '<script type="text/javascript">/*<![CDATA[*/setProgressBarClass("hadError");/*]]>*/</script>
<h2 class="hadError">' . $this->translate('testing_failure') . '</h2>';
} else {
$testStatistics = '<script type="text/javascript">/*<![CDATA[*/setProgressBarClass("hadFailure");/*]]>*/</script>
<h2 class="hadFailure">' . $this->translate('testing_failure') . '</h2>';
}
}
$testStatistics .= '<p>' . $testResult->count() . ' ' . $this->translate('tests_total') . ', ' . $this->testListener->assertionCount() . ' ' . $this->translate('assertions_total') . ', ' . $testResult->failureCount() . ' ' . $this->translate('tests_failures') . ', ' . $testResult->skippedCount() . ' ' . $this->translate('tests_skipped') . ', ' . $testResult->notImplementedCount() . ' ' . $this->translate('tests_incomplete') . ', ' . $testResult->errorCount() . ' ' . $this->translate('tests_errors') . ', <span title="' . $this->testStatistics->getTime() . ' ' . $this->translate('tests_seconds') . '">' . round($this->testStatistics->getTime(), 3) . ' ' . $this->translate('tests_seconds') . ', </span>' . t3lib_div::formatSize($this->testStatistics->getMemory()) . 'B (' . $this->testStatistics->getMemory() . ' B) ' . $this->translate('tests_leaks') . '</p>';
$this->outputService->output($testStatistics);
}
示例9: printResult
public function printResult(\PHPUnit_Framework_TestResult $result)
{
$upLine = str_repeat($this->colors ? '▁' : '-', $this->maxColumns);
$dnLine = str_repeat($this->colors ? '▔' : '-', $this->maxColumns);
$arrow = $this->colors ? '❯' : '=>';
$this->printFailures();
if (!count($this->exceptions)) {
$ch = $this->colors ? ' ✔' : '';
$upLine = "[32m" . $upLine . "\n[0m";
$dnLine = "[32m" . $dnLine . "\n[0m";
$str = "[32m{$ch}[0m OK {$arrow} Passed %s of %s";
$str = sprintf($str, count($result->passed()), $result->count());
} else {
$ch = $this->colors ? ' ✖' : '';
$upLine = "[31m" . $upLine . "\n[0m";
$dnLine = "[31m" . $dnLine . "\n[0m";
$str = "[31m{$ch}[0m KO {$arrow} Failed %s of %s";
$str = sprintf($str, $result->failureCount() + $result->errorCount(), $result->count());
}
if (!$result->allCompletlyImplemented()) {
$pair = array();
if ($result->notImplementedCount() > 0) {
$pair[] = $result->notImplementedCount() . ' not implemented';
}
if ($result->skippedCount() > 0) {
$pair[] = $result->skippedCount() . ' skipped';
}
$str .= " with " . implode(' and ', $pair);
}
// Calculate time and peak memory usage
$time = number_format($result->time(), 2);
$mem = memory_get_peak_usage();
$mem = round($mem / 1024 / 1024);
// Add time spent
$str .= " [30;1m({$time}s {$mem}Mb)\n[0m";
// Clean up the line above and print there
$this->write("[1A[2K");
$this->write($upLine);
$this->write($str);
$this->write($dnLine);
}
示例10: getExitStatus
/**
* Compute a shell exit status for the given result.
* Behaves like PHPUnit_TextUI_Command.
*
* @param PHPUnit_Framework_TestResult The test result object.
*
* @return int The shell exit code.
* @deprecated 1.1.0 Use AgaviPhpUnitCli
*/
public static function getExitStatus(PHPUnit_Framework_TestResult $result)
{
if ($result->wasSuccessful()) {
return PHPUnit_TextUI_TestRunner::SUCCESS_EXIT;
} elseif ($result->errorCount()) {
return PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT;
} else {
return PHPUnit_TextUI_TestRunner::FAILURE_EXIT;
}
}
示例11: formatTestResult
public static function formatTestResult(\PHPUnit_Framework_TestResult $result, $assertions)
{
$tests = $result->count();
$errors = $result->errorCount();
$failures = $result->failureCount();
$skipped = $result->skippedCount();
$incomplete = $result->notImplementedCount();
$msg = self::formatResultPart($errors, 'error', 's');
$msg .= self::formatResultPart($failures, 'failure', 's');
$msg .= self::formatResultPart($skipped, 'skipped');
$msg .= self::formatResultPart($incomplete, 'incomplete');
return sprintf('%s (%d %s, %d %s%s)', $result->wasSuccessful() ? 'OK' : 'FAILED', $tests, $tests != 1 ? 'tests' : 'test', $assertions, $assertions != 1 ? 'assertions' : 'assertion', $msg);
}
示例12: printResult
public function printResult(PHPUnit_Framework_TestResult $result)
{
echo '<h1>QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - PHPUnit ' . PHPUnit_Runner_Version::id() . '</h1>';
foreach ($this->results as $suiteName => $suite) {
$strHtml = "<b>{$suiteName}</b><br />";
foreach ($suite as $testName => $test) {
$status = $test['status'];
$status = ucfirst($status);
if ($test['status'] !== 'passed') {
$status = '<span style="color:red">' . $status . '</span>';
} else {
$status = '<span style="color:green">' . $status . '</span>';
}
$strHtml .= "{$status}: {$testName}";
$strHtml = "{$strHtml}<br />";
if (isset($test['errors'])) {
foreach ($test['errors'] as $error) {
$strHtml .= nl2br(htmlentities($error['e']->__toString())) . '<br />';
}
}
if (isset($test['results'])) {
foreach ($test['results'] as $error) {
$strMessage = $error['e']->toString() . "\n";
// get first line
$lines = explode("\n", PHPUnit_Util_Filter::getFilteredStacktrace($error['e']));
$strMessage .= $lines[0] . "\n";
$strHtml .= nl2br(htmlentities($strMessage)) . '<br />';
}
}
}
echo $strHtml;
}
$str = "\nRan " . $result->count() . " tests in " . $result->time() . " seconds.\n";
$str .= $result->failureCount() . " assertions failed.\n";
$str .= $result->errorCount() . " exceptions were thrown.\n";
echo nl2br($str);
}
示例13: printFooter
/**
* @param PHPUnit_Framework_TestResult $result
* @access protected
*/
protected function printFooter(PHPUnit_Framework_TestResult $result)
{
if ($result->wasSuccessful()) {
printf("\nOK (%d test%s)\n", $result->runCount(), $result->runCount() == 1 ? '' : 's');
} else {
printf("\nFAILURES!!!\nTests run: %d, Failures: %d, Errors: %d.\n", $result->runCount(), $result->failureCount(), $result->errorCount());
}
}