diff --git a/ChangeLog-8.5.md b/ChangeLog-8.5.md index d4254174c57..11287e37980 100644 --- a/ChangeLog-8.5.md +++ b/ChangeLog-8.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 8.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [8.5.30] - 2022-MM-DD + +### Fixed + +* [#4913](https://github.com/sebastianbergmann/phpunit/issues/4913): Failed `assert()` should show a backtrace + ## [8.5.29] - 2022-08-22 ### Changed @@ -239,6 +245,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil * [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable` * [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside +[8.5.30]: https://github.com/sebastianbergmann/phpunit/compare/8.5.29...8.5 [8.5.29]: https://github.com/sebastianbergmann/phpunit/compare/8.5.28...8.5.29 [8.5.28]: https://github.com/sebastianbergmann/phpunit/compare/8.5.27...8.5.28 [8.5.27]: https://github.com/sebastianbergmann/phpunit/compare/8.5.26...8.5.27 diff --git a/src/Framework/TestResult.php b/src/Framework/TestResult.php index 268a8c7d80f..e72bd260a09 100644 --- a/src/Framework/TestResult.php +++ b/src/Framework/TestResult.php @@ -740,7 +740,9 @@ function_exists('xdebug_start_function_monitor'); $e->getMessage(), $frame['file'] ?? $e->getFile(), $frame['line'] ?? $e->getLine() - ) + ), + 0, + $e ); } catch (Warning $e) { $warning = true; diff --git a/src/TextUI/ResultPrinter.php b/src/TextUI/ResultPrinter.php index c4d06b3d243..51b03309412 100644 --- a/src/TextUI/ResultPrinter.php +++ b/src/TextUI/ResultPrinter.php @@ -23,6 +23,7 @@ use function str_pad; use function str_repeat; use function strlen; +use function trim; use function vsprintf; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Exception; @@ -367,7 +368,7 @@ protected function printDefectTrace(TestFailure $defect): void $this->write((string) $e); while ($e = $e->getPrevious()) { - $this->write("\nCaused by\n" . $e); + $this->write("\nCaused by\n" . trim((string) $e) . "\n"); } } diff --git a/tests/end-to-end/generic/assertion.phpt b/tests/end-to-end/generic/assertion.phpt index 5fc273a2d59..83c97779006 100644 --- a/tests/end-to-end/generic/assertion.phpt +++ b/tests/end-to-end/generic/assertion.phpt @@ -29,5 +29,10 @@ There was 1 failure: 1) PHPUnit\TestFixture\AssertionExampleTest::testOne assert(false) in %sAssertionExample.php:%d +Caused by +AssertionError: assert(false) in %sAssertionExample.php:%d +Stack trace: +%A + FAILURES! Tests: 1, Assertions: 1, Failures: 1.