diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php index 339ff3f8d417e..df2de43cf1163 100644 --- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php +++ b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\PhpUnit; use Doctrine\Common\Annotations\AnnotationRegistry; +use SebastianBergmann\Diff\Differ; /** * Collects and replays skipped tests. @@ -191,11 +192,11 @@ public function endTest(\PHPUnit_Framework_Test $test, $time) restore_error_handler(); if (!in_array($test->getStatus(), array(\PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED, \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE, \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE, \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR), true)) { - try { - $prefix = "@expectedDeprecation:\n"; - $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); - } catch (\PHPUnit_Framework_AssertionFailedError $e) { - $test->getTestResultObject()->addFailure($test, $e, $time); + if ($this->gatheredDeprecations !== $this->expectedDeprecations) { + $differ = new Differ("--- Expected\n+++ Actual\n"); + $test->getTestResultObject()->addFailure($test, new \PHPUnit_Framework_AssertionFailedError( + "Failed asserting expected deprecations.\n\n".$differ->diff(implode("\n", $this->gatheredDeprecations), implode("\n", $this->expectedDeprecations)) + ), $time); } }