本文整理汇总了PHP中PHPUnit_Framework_AssertionFailedError::getTrace方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_AssertionFailedError::getTrace方法的具体用法?PHP PHPUnit_Framework_AssertionFailedError::getTrace怎么用?PHP PHPUnit_Framework_AssertionFailedError::getTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_AssertionFailedError
的用法示例。
在下文中一共展示了PHPUnit_Framework_AssertionFailedError::getTrace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
}
示例2: 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();
}
示例3: 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();
}
示例4: addFailure
/**
* A test has failed.
*
* @param PHPUnit_Framework_Test $test the test that has failed
* @param PHPUnit_Framework_AssertionFailedError $e the failed assertion
* @param float $time ?
*
* @return void
*
* @throws InvalidArgumentException
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
if (!$test instanceof PHPUnit_Framework_TestCase) {
throw new InvalidArgumentException('addFailure needs $test to be a PHPUnit_Framework_TestCase.', 1334308954);
}
/** @var PHPUnit_Framework_TestCase $test */
$testCaseTraceArr = $this->getFirstNonPhpUnitTrace($e->getTrace());
$fileName = str_replace(PATH_site, '', $testCaseTraceArr['file']);
$this->outputService->output('<script type="text/javascript">/*<![CDATA[*/setProgressBarClass("hadFailure");/*]]>*/</script>' . '<script type="text/javascript">/*<![CDATA[*/setClass("testcaseNum-' . $this->currentTestNumber . '_' . $this->currentDataProviderNumber . '","testcaseFailure");/*]]>*/</script>' . '<strong>Failure</strong> in test case <em>' . htmlspecialchars($test->getName()) . '</em>' . '<br />File: <em>' . $fileName . '</em>' . '<br />Line: <em>' . $testCaseTraceArr['line'] . '</em>');
if (method_exists($e, 'getDescription')) {
$message = $e->getDescription();
} else {
$message = $e->getMessage();
}
$this->outputService->output('<div class="message">' . nl2br(htmlspecialchars($message)) . '</div>');
if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
/** @var PHPUnit_Framework_ExpectationFailedException $e */
$comparisonFailure = $e->getComparisonFailure();
if ($comparisonFailure instanceof ComparisonFailure) {
/** @var ComparisonFailure $comparisonFailure */
$expected = $comparisonFailure->getExpectedAsString();
$actual = $comparisonFailure->getActualAsString();
/** @var DiffUtility $diff */
$diff = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
$this->outputService->output('<code>' . $diff->makeDiffDisplay($actual, $expected) . '</code>');
}
}
}
示例5: getTraceFiles
/**
* Function to extract our test file information from the $e stack trace.
* Makes the error reporting more readable, since it filters out all of the PHPUnit files.
*
* @param PHPUnit_Framework_AssertionFailedError $e
* @return string with selected files based on path
*/
public function getTraceFiles($e)
{
$trace = $e->getTrace();
$path = $this->cfg->folder . $this->cfg->path;
$path = str_replace('\\', '/', $path);
$message = '';
foreach ($trace as $traceLine) {
if (isset($traceLine['file'])) {
$file = str_replace('\\', '/', $traceLine['file']);
if (stripos($file, $path) !== false) {
$message .= "\n" . $traceLine['file'] . '(' . $traceLine['line'] . '): ' . $traceLine['class'] . $traceLine['type'] . $traceLine['function'];
}
}
}
return $e->toString() . $message;
}
示例6: addFailure
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
if ($test instanceof PHPUnit_Framework_Warning) {
return;
}
$message = $e->getMessage();
print traceCommand("testFailed", "name", $test->getName(), "message", $message, "details", getTraceMessage($e->getTrace(), $this->myfilename));
flush();
}