From 5e7ac12c4d670d64b85c51ebee2fbff2ed40aa52 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 25 Mar 2024 22:59:29 +0000 Subject: [PATCH] Issue #3432171 by mondrake: dump() no longer produces output in PHPUnit tests running under PHP 8.3 (cherry picked from commit 80139bdb8e968759d757293432289a0ea175526f) --- core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php | 4 ++-- core/tests/Drupal/KernelTests/KernelTestBaseTest.php | 4 ++-- core/tests/Drupal/TestTools/TestVarDumper.php | 4 ++-- core/tests/Drupal/Tests/UnitTestCaseTest.php | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index 649b4d04762..301aaa43cee 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -601,11 +601,11 @@ class BrowserTestBaseTest extends BrowserTestBase { * Tests the dump() function provided by the var-dumper Symfony component. */ public function testVarDump() { - // Append the stream capturer to the STDOUT stream, so that we can test the + // Append the stream capturer to the STDERR stream, so that we can test the // dump() output and also prevent it from actually outputting in this // particular test. stream_filter_register("capture", StreamCapturer::class); - stream_filter_append(STDOUT, "capture"); + stream_filter_append(STDERR, "capture"); // Dump some variables to check that dump() in test code produces output // on the command line that is running the test. diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php index 4df6d09c167..49aa82d68cd 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php +++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php @@ -378,11 +378,11 @@ class KernelTestBaseTest extends KernelTestBase { * Tests the dump() function provided by the var-dumper Symfony component. */ public function testVarDump() { - // Append the stream capturer to the STDOUT stream, so that we can test the + // Append the stream capturer to the STDERR stream, so that we can test the // dump() output and also prevent it from actually outputting in this // particular test. stream_filter_register("capture", StreamCapturer::class); - stream_filter_append(STDOUT, "capture"); + stream_filter_append(STDERR, "capture"); // Dump some variables. $this->enableModules(['system', 'user']); diff --git a/core/tests/Drupal/TestTools/TestVarDumper.php b/core/tests/Drupal/TestTools/TestVarDumper.php index 67d6136e155..dbf5af90f97 100644 --- a/core/tests/Drupal/TestTools/TestVarDumper.php +++ b/core/tests/Drupal/TestTools/TestVarDumper.php @@ -22,7 +22,7 @@ class TestVarDumper { public static function cliHandler($var) { $cloner = new VarCloner(); $dumper = new CliDumper(); - fwrite(STDOUT, "\n"); + fwrite(STDERR, "\n"); $dumper->setColors(TRUE); $dumper->dump( $cloner->cloneVar($var), @@ -30,7 +30,7 @@ class TestVarDumper { // A negative depth means "end of dump". if ($depth >= 0) { // Adds a two spaces indentation to the line. - fwrite(STDOUT, str_repeat($indent_pad, $depth) . $line . "\n"); + fwrite(STDERR, str_repeat($indent_pad, $depth) . $line . "\n"); } } ); diff --git a/core/tests/Drupal/Tests/UnitTestCaseTest.php b/core/tests/Drupal/Tests/UnitTestCaseTest.php index 4d5a7948a87..033923cf1c4 100644 --- a/core/tests/Drupal/Tests/UnitTestCaseTest.php +++ b/core/tests/Drupal/Tests/UnitTestCaseTest.php @@ -17,11 +17,11 @@ class UnitTestCaseTest extends UnitTestCase { * Tests the dump() function in a test run in the same process. */ public function testVarDumpSameProcess() { - // Append the stream capturer to the STDOUT stream, so that we can test the + // Append the stream capturer to the STDERR stream, so that we can test the // dump() output and also prevent it from actually outputting in this // particular test. stream_filter_register("capture", StreamCapturer::class); - stream_filter_append(STDOUT, "capture"); + stream_filter_append(STDERR, "capture"); // Dump some variables. $object = (object) [ @@ -40,11 +40,11 @@ class UnitTestCaseTest extends UnitTestCase { * @runInSeparateProcess */ public function testVarDumpSeparateProcess() { - // Append the stream capturer to the STDOUT stream, so that we can test the + // Append the stream capturer to the STDERR stream, so that we can test the // dump() output and also prevent it from actually outputting in this // particular test. stream_filter_register("capture", StreamCapturer::class); - stream_filter_append(STDOUT, "capture"); + stream_filter_append(STDERR, "capture"); // Dump some variables. $object = (object) [