From 6fa416062a3021771f589e84009a3bc7fc4e69e5 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 30 Dec 2023 11:32:43 +0100 Subject: [PATCH] Closes #5518 --- ChangeLog-10.5.md | 7 ++++ src/TextUI/Output/Facade.php | 10 ++--- .../testdox/_files/DeprecationTest.php | 23 ++++++++++++ .../end-to-end/testdox/_files/NoticeTest.php | 23 ++++++++++++ .../end-to-end/testdox/_files/WarningTest.php | 23 ++++++++++++ ...est-that-triggers-deprecation-default.phpt | 26 +++++++++++++ ...est-that-triggers-deprecation-details.phpt | 37 +++++++++++++++++++ .../test-that-triggers-notice-default.phpt | 26 +++++++++++++ .../test-that-triggers-notice-details.phpt | 37 +++++++++++++++++++ .../test-that-triggers-warning-default.phpt | 26 +++++++++++++ .../test-that-triggers-warning-details.phpt | 37 +++++++++++++++++++ 11 files changed, 270 insertions(+), 5 deletions(-) create mode 100644 tests/end-to-end/testdox/_files/DeprecationTest.php create mode 100644 tests/end-to-end/testdox/_files/NoticeTest.php create mode 100644 tests/end-to-end/testdox/_files/WarningTest.php create mode 100644 tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt create mode 100644 tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt create mode 100644 tests/end-to-end/testdox/test-that-triggers-notice-default.phpt create mode 100644 tests/end-to-end/testdox/test-that-triggers-notice-details.phpt create mode 100644 tests/end-to-end/testdox/test-that-triggers-warning-default.phpt create mode 100644 tests/end-to-end/testdox/test-that-triggers-warning-details.phpt diff --git a/ChangeLog-10.5.md b/ChangeLog-10.5.md index af8e707128d..74e70c62699 100644 --- a/ChangeLog-10.5.md +++ b/ChangeLog-10.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [10.5.6] - 202Y-MM-DD + +### Fixed + +* [#5518](https://github.com/sebastianbergmann/phpunit/issues/5518): Details about deprecations, notices, and warnings are not displayed when the TestDox result printer is used + ## [10.5.5] - 2023-12-27 ### Fixed @@ -62,6 +68,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi * [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification +[10.5.6]: https://github.com/sebastianbergmann/phpunit/compare/10.5.5...10.5 [10.5.5]: https://github.com/sebastianbergmann/phpunit/compare/10.5.4...10.5.5 [10.5.4]: https://github.com/sebastianbergmann/phpunit/compare/10.5.3...10.5.4 [10.5.3]: https://github.com/sebastianbergmann/phpunit/compare/10.5.2...10.5.3 diff --git a/src/TextUI/Output/Facade.php b/src/TextUI/Output/Facade.php index 23f15236822..49b6d28db3a 100644 --- a/src/TextUI/Output/Facade.php +++ b/src/TextUI/Output/Facade.php @@ -199,11 +199,11 @@ private static function createResultPrinter(Configuration $configuration): void false, false, false, - false, - false, - false, - false, - false, + $configuration->displayDetailsOnTestsThatTriggerDeprecations(), + $configuration->displayDetailsOnTestsThatTriggerErrors(), + $configuration->displayDetailsOnTestsThatTriggerNotices(), + $configuration->displayDetailsOnTestsThatTriggerWarnings(), + $configuration->reverseDefectList(), ); } diff --git a/tests/end-to-end/testdox/_files/DeprecationTest.php b/tests/end-to-end/testdox/_files/DeprecationTest.php new file mode 100644 index 00000000000..12b3dbfdb72 --- /dev/null +++ b/tests/end-to-end/testdox/_files/DeprecationTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class DeprecationTest extends TestCase +{ + public function testDeprecation(): void + { + trigger_error('deprecation', E_USER_DEPRECATED); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/testdox/_files/NoticeTest.php b/tests/end-to-end/testdox/_files/NoticeTest.php new file mode 100644 index 00000000000..217e8857fdc --- /dev/null +++ b/tests/end-to-end/testdox/_files/NoticeTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class NoticeTest extends TestCase +{ + public function testNotice(): void + { + trigger_error('notice', E_USER_NOTICE); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/testdox/_files/WarningTest.php b/tests/end-to-end/testdox/_files/WarningTest.php new file mode 100644 index 00000000000..48925d3cc79 --- /dev/null +++ b/tests/end-to-end/testdox/_files/WarningTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class WarningTest extends TestCase +{ + public function testWarning(): void + { + trigger_error('warning', E_USER_WARNING); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt b/tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt new file mode 100644 index 00000000000..4804486d150 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt @@ -0,0 +1,26 @@ +--TEST-- +TestDox: Test triggers deprecation and --display-deprecations is not used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Deprecation (PHPUnit\TestFixture\TestDox\Deprecation) + ✔ Deprecation + +OK, but there were issues! +Tests: 1, Assertions: 1, Deprecations: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt b/tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt new file mode 100644 index 00000000000..9f12e35ae61 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt @@ -0,0 +1,37 @@ +--TEST-- +TestDox: Test triggers deprecation and --display-deprecations is used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Deprecation (PHPUnit\TestFixture\TestDox\Deprecation) + ✔ Deprecation + +1 test triggered 1 deprecation: + +1) %sDeprecationTest.php:19 +deprecation + +Triggered by: + +* PHPUnit\TestFixture\TestDox\DeprecationTest::testDeprecation + %sDeprecationTest.php:17 + +OK, but there were issues! +Tests: 1, Assertions: 1, Deprecations: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-notice-default.phpt b/tests/end-to-end/testdox/test-that-triggers-notice-default.phpt new file mode 100644 index 00000000000..fe20394f3a3 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-notice-default.phpt @@ -0,0 +1,26 @@ +--TEST-- +TestDox: Test triggers notice and --display-notices is not used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Notice (PHPUnit\TestFixture\TestDox\Notice) + ✔ Notice + +OK, but there were issues! +Tests: 1, Assertions: 1, Notices: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-notice-details.phpt b/tests/end-to-end/testdox/test-that-triggers-notice-details.phpt new file mode 100644 index 00000000000..235760aa09e --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-notice-details.phpt @@ -0,0 +1,37 @@ +--TEST-- +TestDox: Test triggers notice and --display-notices is used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Notice (PHPUnit\TestFixture\TestDox\Notice) + ✔ Notice + +1 test triggered 1 notice: + +1) %sNoticeTest.php:19 +notice + +Triggered by: + +* PHPUnit\TestFixture\TestDox\NoticeTest::testNotice + %sNoticeTest.php:17 + +OK, but there were issues! +Tests: 1, Assertions: 1, Notices: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-warning-default.phpt b/tests/end-to-end/testdox/test-that-triggers-warning-default.phpt new file mode 100644 index 00000000000..09320a99fe9 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-warning-default.phpt @@ -0,0 +1,26 @@ +--TEST-- +TestDox: Test triggers warning and --display-warning is not used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Warning (PHPUnit\TestFixture\TestDox\Warning) + ✔ Warning + +OK, but there were issues! +Tests: 1, Assertions: 1, Warnings: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-warning-details.phpt b/tests/end-to-end/testdox/test-that-triggers-warning-details.phpt new file mode 100644 index 00000000000..73c28ef9279 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-warning-details.phpt @@ -0,0 +1,37 @@ +--TEST-- +TestDox: Test triggers warning and --display-warning is used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Warning (PHPUnit\TestFixture\TestDox\Warning) + ✔ Warning + +1 test triggered 1 warning: + +1) %sWarningTest.php:19 +warning + +Triggered by: + +* PHPUnit\TestFixture\TestDox\WarningTest::testWarning + %sWarningTest.php:17 + +OK, but there were issues! +Tests: 1, Assertions: 1, Warnings: 1.