本文整理汇总了PHP中PHPUnit_Framework_AssertionFailedError类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_AssertionFailedError类的具体用法?PHP PHPUnit_Framework_AssertionFailedError怎么用?PHP PHPUnit_Framework_AssertionFailedError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Framework_AssertionFailedError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onNotSuccessfulTest
protected function onNotSuccessfulTest(\Exception $e)
{
if ($e instanceof PredictionException) {
$e = new \PHPUnit_Framework_AssertionFailedError($e->getMessage(), $e->getCode(), $e);
}
return parent::onNotSuccessfulTest($e);
}
示例2: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->write('fail: ' . $e->getMessage());
$trace = current(PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE));
$this->write('trace: ' . print_r($trace, 1));
$this->currentTestPass = FALSE;
}
示例3: addFailure
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$class = get_class($test);
$message = $this->escape($e->getMessage());
$trace = $this->escape($e->getTraceAsString());
echo "##teamcity[testFailed type='failure' name='{$class}.{$test->getName()}' message='{$message}'" . " details='{$trace}']\n";
}
示例4: paintFail
/**
* Paints a failing test.
*
* @param PHPUnit_Framework_AssertionFailedError $message Failure object displayed in
* the context of the other tests.
* @return void
*/
public function paintFail($message)
{
$context = $message->getTrace();
$realContext = $context[3];
$context = $context[2];
printf("FAIL on line %s\n%s in\n%s %s()\n\n", $context['line'], $message->toString(), $context['file'], $realContext['function']);
}
示例5: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
* @return void
* @author Karsten Dambekalns <karsten@typo3.org>
*/
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
$testCaseTraceArr = $this->getFirstNonPHPUnitTrace($e->getTrace());
$fileName = $testCaseTraceArr['file'];
echo '<script type="text/javascript">document.getElementById("progress-bar").style.backgroundImage = "url(_Resources/Static/Packages/Testing/Media/indicator_red.gif)";</script>
<div class="test failure"><strong>Failure</strong> in <em>' . $test->getName() . '</em> ' . '<img src="_Resources/Static/Packages/Testing/Media/failure.png" alt="Detail" onclick="if(document.getElementById(\'test' . $this->currentTestNumber . '\').style.display==\'none\') document.getElementById(\'test' . $this->currentTestNumber . '\').style.display=\'block\'; else document.getElementById(\'test' . $this->currentTestNumber . '\').style.display=\'none\'" />' . '<div class="testdetail" id="test' . $this->currentTestNumber . '">' . $fileName . ':' . $testCaseTraceArr['line'] . '<br />' . htmlspecialchars($e->getMessage()) . '<br /><div class="testoutput">' . $this->getTestOutput() . '</div></div></div>';
$this->resultArray['failure']++;
$this->flushOutputBuffer();
}
示例6: addFailure
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->_fails += 1;
if ($this->_fails == 1) {
echo "\n<div class=\"failure\">";
}
printf("Test '%s' failed : %s.<br />\n<pre>%s</pre>\n", $test->getName(), htmlentities($e->getMessage()), (string) $e->getTraceAsString());
//echo("Failure $this->_fails : $t<br>\n");
}
示例7: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
* @return void
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$message = sprintf("%s FAILURE: %s (Duration: %s sec)", str_repeat(' ', $this->level), str_replace("\n", " ", $e->getMessage()), $this->getDuration());
if ($this->colors) {
$this->write("[41;37m{$message}[0m" . "\n");
} else {
$this->write($message . "\n");
}
$this->lastTestFailed = TRUE;
}
示例8: addFailure
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
if ($this->verbose) {
echo " FAIL: '" . $e->getMessage() . "'\n" . $e->getTraceAsString();
}
parent::addFailure($test, $e, $time);
if ($this->_blDBResetPerTest && !isset($test->blNoDbResetAfterTest)) {
$this->_oDBMaintenance->restoreDB($this->_iDBChangeMode, $this->_iDBChangeOutput);
echo "|";
}
}
示例9: printFailure
private function printFailure(PHPUnit_Framework_AssertionFailedError $e)
{
YTestLogger::indent();
YTestLogger::say($e->getMessage() . "\n");
foreach ($e->getTrace() as $frame) {
if (array_key_exists('file', $frame)) {
$file = $frame['file'];
if (strpos($file, 'PHPUnit/') || strpos($file, 'CustomTestCase')) {
break;
}
YTestLogger::say($file . ":" . $frame['line'] . "\n");
}
}
YTestLogger::dedent();
}
示例10: addFailure
/**
* A failure occurred.
*
* @todo Add check that $test is instance of PHPUnit_Framework_TestCase
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$failures = array();
$testResult = $test->getTestResultObject();
/** @var $failure PHPUnit_Framework_TestFailure */
foreach ($testResult->failures() as $failure) {
$hash = "{$e->getMessage()} {$e->getTraceAsString()}";
if (isset($failures[$hash])) {
continue;
}
$array = array('type' => self::MESSAGE_COMPARISON_FAILURE, 'name' => $test->getName(), 'message' => $e->getMessage(), 'details' => $e->getTraceAsString());
/** @var $exception PHPUnit_Framework_ExpectationFailedException */
$exception = $failure->thrownException();
$comparisonFailure = $exception->getComparisonFailure();
if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure) {
$array += array('expected' => $comparisonFailure->getExpectedAsString(), 'actual' => $comparisonFailure->getActualAsString());
}
$message = $this->getServiceMessage(self::MESSAGE_TEST_FAILED, $array);
$this->write($message);
$failures[$hash] = true;
}
}
示例11: addFailure
/**
* Adds the failure detail to the current test and increases the failure
* count for the current suite
*
* @param PHPUnit_Framework_Test $test current test that is being run
* @param PHPUnit_Framework_AssertionFailedError $e PHPUnit error
* @param int $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
if ($this->currentSuite) {
$this->currentSuite['failures']++;
} else {
$this->currentSession['failures']++;
}
$this->addStatus(TEST_FAILURE, $e->toString(), $this->getTestException($test, $e), $e->getTrace());
}
示例12: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
*/
public function run(PHPUnit_Framework_Test $test)
{
PHPUnit_Framework_Assert::resetCount();
if ($test instanceof PHPUnit_Framework_TestCase) {
$test->setRegisterMockObjectsFromTestArgumentsRecursively($this->registerMockObjectsFromTestArgumentsRecursively);
}
$error = false;
$failure = false;
$warning = false;
$incomplete = false;
$risky = false;
$skipped = false;
$this->startTest($test);
$errorHandlerSet = false;
if ($this->convertErrorsToExceptions) {
$oldErrorHandler = set_error_handler(['PHPUnit_Util_ErrorHandler', 'handleError'], E_ALL | E_STRICT);
if ($oldErrorHandler === null) {
$errorHandlerSet = true;
} else {
restore_error_handler();
}
}
$collectCodeCoverage = $this->codeCoverage !== null && !$test instanceof PHPUnit_Framework_WarningTestCase;
if ($collectCodeCoverage) {
$this->codeCoverage->start($test);
}
$monitorFunctions = $this->beStrictAboutResourceUsageDuringSmallTests && !$test instanceof PHPUnit_Framework_WarningTestCase && $test->getSize() == PHPUnit_Util_Test::SMALL && function_exists('xdebug_start_function_monitor');
if ($monitorFunctions) {
xdebug_start_function_monitor(ResourceOperations::getFunctions());
}
PHP_Timer::start();
try {
if (!$test instanceof PHPUnit_Framework_WarningTestCase && $test->getSize() != PHPUnit_Util_Test::UNKNOWN && $this->enforceTimeLimit && extension_loaded('pcntl') && class_exists('PHP_Invoker')) {
switch ($test->getSize()) {
case PHPUnit_Util_Test::SMALL:
$_timeout = $this->timeoutForSmallTests;
break;
case PHPUnit_Util_Test::MEDIUM:
$_timeout = $this->timeoutForMediumTests;
break;
case PHPUnit_Util_Test::LARGE:
$_timeout = $this->timeoutForLargeTests;
break;
}
$invoker = new PHP_Invoker();
$invoker->invoke([$test, 'runBare'], [], $_timeout);
} else {
$test->runBare();
}
} catch (PHPUnit_Framework_MockObject_Exception $e) {
$e = new PHPUnit_Framework_Warning($e->getMessage());
$warning = true;
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = true;
if ($e instanceof PHPUnit_Framework_RiskyTestError) {
$risky = true;
} elseif ($e instanceof PHPUnit_Framework_IncompleteTestError) {
$incomplete = true;
} elseif ($e instanceof PHPUnit_Framework_SkippedTestError) {
$skipped = true;
}
} catch (AssertionError $e) {
$test->addToAssertionCount(1);
$failure = true;
$frame = $e->getTrace()[0];
$e = new PHPUnit_Framework_AssertionFailedError(sprintf('%s in %s:%s', $e->getMessage(), $frame['file'], $frame['line']));
} catch (PHPUnit_Framework_Warning $e) {
$warning = true;
} catch (PHPUnit_Framework_Exception $e) {
$error = true;
} catch (Throwable $e) {
$e = new PHPUnit_Framework_ExceptionWrapper($e);
$error = true;
}
$time = PHP_Timer::stop();
$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
if ($monitorFunctions) {
$blacklist = new PHPUnit_Util_Blacklist();
$functions = xdebug_get_monitored_functions();
xdebug_stop_function_monitor();
foreach ($functions as $function) {
if (!$blacklist->isBlacklisted($function['filename'])) {
$this->addFailure($test, new PHPUnit_Framework_RiskyTestError(sprintf('%s() used in %s:%s', $function['function'], $function['filename'], $function['lineno'])), $time);
}
}
}
if ($this->beStrictAboutTestsThatDoNotTestAnything && $test->getNumAssertions() == 0) {
$risky = true;
}
if ($collectCodeCoverage) {
$append = !$risky && !$incomplete && !$skipped;
$linesToBeCovered = [];
$linesToBeUsed = [];
if ($append && $test instanceof PHPUnit_Framework_TestCase) {
try {
//.........这里部分代码省略.........
示例13: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->_messages[] = "Test FAILED: " . $test->getName() . ": " . $e->getMessage();
}
示例14: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->log->err(sprintf('Test "%s" failed: %s', $test->getName(), $e->getMessage()));
}
示例15: addFailure
/**
* Adds the failure detail to the current test and increases the failure
* count for the current suite
*
* @access public
* @param obj PHPUnit_Framework_Test, current test that is being run
* @param obj PHPUnit_Framework_AssertationFailedError, PHPUnit error
* @return void
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->currentSuite['failures']++;
$this->currentTest['status'] = TEST_FAILURE;
$this->currentTest['message'] = $e->toString();
$this->currentTest['exception'] = $this->getTestException($test, $e);
$this->currentTest['trace'] = $e->getTrace();
}