本文整理汇总了PHP中PHPUnit_Framework_TestResult::failures方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestResult::failures方法的具体用法?PHP PHPUnit_Framework_TestResult::failures怎么用?PHP PHPUnit_Framework_TestResult::failures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestResult
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestResult::failures方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromPHPUnitTestResult
/**
* Creates a Streamwide_PHPUnit_Runner_TestCaseResult from a PHPUnit_Framework_TestResult.
*
* @param Streamwide_PHPUnit_Runner_TestCase $testCase test case
* @param PHPUnit_Framework_TestResult $testResult test result
* @return Streamwide_PHPUnit_Runner_TestCaseResult test case result
*/
public static function fromPHPUnitTestResult(Streamwide_PHPUnit_Runner_TestCase $testCase, PHPUnit_Framework_TestResult $testResult)
{
$passed = $testResult->passed();
$skipped = $testResult->skipped();
$errors = $testResult->errors();
$failures = $testResult->failures();
$notImplemented = $testResult->notImplemented();
$time = $testResult->time();
$statusMessage = null;
$codeCoverage = null;
if (!empty($passed)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::PASSED;
$codeCoverage = $testResult->getCodeCoverageInformation();
} else {
if (!empty($skipped)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::SKIPPED;
$statusMessage = $skipped[0]->toStringVerbose(true);
} else {
if (!empty($notImplemented)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::NOT_IMPLEMENTED;
$statusMessage = $notImplemented[0]->toStringVerbose(true);
} else {
if (!empty($errors)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::ERROR;
$statusMessage = $errors[0]->toStringVerbose(true) . PHPUnit_Util_Filter::getFilteredStacktrace($errors[0]->thrownException());
} else {
if (!empty($failures)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::FAILED;
$statusMessage = $failures[0]->toStringVerbose(true) . PHPUnit_Util_Filter::getFilteredStacktrace($failures[0]->thrownException());
}
}
}
}
}
$testCaseResult = new Streamwide_PHPUnit_Runner_TestCaseResult($testCase, $status, $statusMessage, null, $time, $codeCoverage);
return $testCaseResult;
}
示例2: printFailures
/**
* @param PHPUnit_Framework_TestResult $result
*/
protected function printFailures(PHPUnit_Framework_TestResult $result)
{
$this->printDefects($result->failures(), $result->failureCount(), 'failure');
}
示例3: parseTestSuite
/**
* Parse the test suite result
*
* @param \PHPUnit_Framework_TestResult $result
* @return array<string,double|integer|array>
*/
private function parseTestSuite($result)
{
$passed = 0;
$error = 0;
$failed = 0;
$notImplemented = 0;
$skipped = 0;
$tests = [];
foreach ($result->passed() as $key => $value) {
$tests[] = $this->parseTest('passed', $key);
$passed++;
}
foreach ($result->failures() as $obj) {
$tests[] = $this->parseTest('failed', $obj);
$failed++;
}
foreach ($result->skipped() as $obj) {
$tests[] = $this->parseTest('skipped', $obj);
$skipped++;
}
foreach ($result->notImplemented() as $obj) {
$tests[] = $this->parseTest('notImplemented', $obj);
$notImplemented++;
}
foreach ($result->errors() as $obj) {
$tests[] = $this->parseTest('error', $obj);
$error++;
}
usort($tests, function ($a, $b) {
return strnatcmp($a['class'], $b['class']);
});
return ['time' => $result->time(), 'total' => count($tests), 'passed' => $passed, 'error' => $error, 'failed' => $failed, 'notImplemented' => $notImplemented, 'skipped' => $skipped, 'tests' => $tests];
}
示例4: lookupResult
/**
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_TestResult $result
* @return mixed
*/
public static function lookupResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result)
{
$testName = self::describe($test);
foreach ($result->errors() as $error) {
if ($testName == self::describe($error->failedTest())) {
return $error;
}
}
foreach ($result->failures() as $failure) {
if ($testName == self::describe($failure->failedTest())) {
return $failure;
}
}
foreach ($result->notImplemented() as $notImplemented) {
if ($testName == self::describe($notImplemented->failedTest())) {
return $notImplemented;
}
}
foreach ($result->skipped() as $skipped) {
if ($testName == self::describe($skipped->failedTest())) {
return $skipped;
}
}
return PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
}
示例5: assertSuccessful
/**
* Asserts that the given result belongs to a test that was
* executed successfully.
*
* @param PHPUnit_Framework_TestResult $result
*/
protected function assertSuccessful(PHPUnit_Framework_TestResult $result)
{
$message = '';
foreach ($result->errors() as $error) {
/* @var $error PHPUnit_Framework_TestFailure */
$message .= $error->getExceptionAsString() . PHP_EOL;
}
foreach ($result->failures() as $failure) {
/* @var $failure PHPUnit_Framework_TestFailure */
$message .= $failure->getExceptionAsString() . PHP_EOL;
}
$this->assertTrue($result->wasSuccessful(), $message);
}