You are here

public function Framework_ConstraintTest::testConstraintException in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php \Framework_ConstraintTest::testConstraintException()

@covers PHPUnit_Framework_Constraint_Exception @covers PHPUnit_Framework_TestFailure::exceptionToString

File

vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php, line 3455

Class

Framework_ConstraintTest
@since Class available since Release 3.0.0

Code

public function testConstraintException() {
  $constraint = new PHPUnit_Framework_Constraint_Exception('FoobarException');
  $exception = new DummyException('Test');
  $stackTrace = $exception
    ->getTraceAsString();
  try {
    $constraint
      ->evaluate($exception);
  } catch (PHPUnit_Framework_ExpectationFailedException $e) {
    $this
      ->assertEquals(<<<EOF
Failed asserting that exception of type "DummyException" matches expected exception "FoobarException". Message was: "Test" at
{<span class="php-variable">$stackTrace</span>}.

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
    return;
  }
  $this
    ->fail();
}