You are here

public function PHPUnit_Util_Log_TAP::addFailure in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/Log/TAP.php \PHPUnit_Util_Log_TAP::addFailure()

A failure occurred.

Parameters

PHPUnit_Framework_Test $test:

PHPUnit_Framework_AssertionFailedError $e:

float $time:

Overrides PHPUnit_Framework_TestListener::addFailure

File

vendor/phpunit/phpunit/src/Util/Log/TAP.php, line 66

Class

PHPUnit_Util_Log_TAP
A TestListener that generates a logfile of the test execution using the Test Anything Protocol (TAP).

Code

public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
  $this
    ->writeNotOk($test, 'Failure');
  $message = explode("\n", PHPUnit_Framework_TestFailure::exceptionToString($e));
  $diagnostic = array(
    'message' => $message[0],
    'severity' => 'fail',
  );
  if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
    $cf = $e
      ->getComparisonFailure();
    if ($cf !== null) {
      $diagnostic['data'] = array(
        'got' => $cf
          ->getActual(),
        'expected' => $cf
          ->getExpected(),
      );
    }
  }
  $yaml = new Symfony\Component\Yaml\Dumper();
  $this
    ->write(sprintf("  ---\n%s  ...\n", $yaml
    ->dump($diagnostic, 2, 2)));
}