You are here

public static function PHPUnit_Framework_TestFailure::exceptionToString in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpunit/phpunit/src/Framework/TestFailure.php \PHPUnit_Framework_TestFailure::exceptionToString()

Returns a description for an exception.

@since Method available since Release 3.2.0

Parameters

Exception $e:

Return value

string

99 calls to PHPUnit_Framework_TestFailure::exceptionToString()
Framework_ConstraintTest::testAttributeEqualTo in vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php
@covers PHPUnit_Framework_Assert::attributeEqualTo @covers PHPUnit_Framework_Constraint_Attribute @covers PHPUnit_Framework_TestFailure::exceptionToString
Framework_ConstraintTest::testAttributeEqualTo2 in vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php
@covers PHPUnit_Framework_Assert::attributeEqualTo @covers PHPUnit_Framework_Constraint_Attribute @covers PHPUnit_Framework_TestFailure::exceptionToString
Framework_ConstraintTest::testAttributeNotEqualTo in vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php
@covers PHPUnit_Framework_Assert::attributeEqualTo @covers PHPUnit_Framework_Assert::logicalNot @covers PHPUnit_Framework_Constraint_Attribute @covers PHPUnit_Framework_Constraint_Not @covers PHPUnit_Framework_TestFailure::exceptionToString
Framework_ConstraintTest::testAttributeNotEqualTo2 in vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php
@covers PHPUnit_Framework_Assert::attributeEqualTo @covers PHPUnit_Framework_Assert::logicalNot @covers PHPUnit_Framework_Constraint_Attribute @covers PHPUnit_Framework_Constraint_Not @covers PHPUnit_Framework_TestFailure::exceptionToString
Framework_ConstraintTest::testConstraintArrayContains in vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php
@covers PHPUnit_Framework_Constraint_TraversableContains @covers PHPUnit_Framework_Constraint::count @covers PHPUnit_Framework_TestFailure::exceptionToString

... See full list

File

vendor/phpunit/phpunit/src/Framework/TestFailure.php, line 84

Class

PHPUnit_Framework_TestFailure
A TestFailure collects a failed test together with the caught exception.

Code

public static function exceptionToString(Exception $e) {
  if ($e instanceof PHPUnit_Framework_SelfDescribing) {
    $buffer = $e
      ->toString();
    if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e
      ->getComparisonFailure()) {
      $buffer = $buffer . $e
        ->getComparisonFailure()
        ->getDiff();
    }
    if (!empty($buffer)) {
      $buffer = trim($buffer) . "\n";
    }
  }
  elseif ($e instanceof PHPUnit_Framework_Error) {
    $buffer = $e
      ->getMessage() . "\n";
  }
  elseif ($e instanceof PHPUnit_Framework_ExceptionWrapper) {
    $buffer = $e
      ->getClassname() . ': ' . $e
      ->getMessage() . "\n";
  }
  else {
    $buffer = get_class($e) . ': ' . $e
      ->getMessage() . "\n";
  }
  return $buffer;
}