From 50c16b799815a825cb1c32dcec304430f55c97f1 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Fri, 2 Oct 2026 16:20:09 +0200 Subject: [PATCH] fix: ignore line endings in console output assertions --- src/Traits/InteractsWithConsole.php | 2 +- tests/app/Command/MultilineCommand.php | 20 ++++++++++++++++++++ tests/src/ConsoleTest.php | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/app/Command/MultilineCommand.php diff --git a/src/Traits/InteractsWithConsole.php b/src/Traits/InteractsWithConsole.php index c77e05c..8868dd3 100644 --- a/src/Traits/InteractsWithConsole.php +++ b/src/Traits/InteractsWithConsole.php @@ -25,7 +25,7 @@ trait InteractsWithConsole $output = $this->runCommand($command, $args); foreach ((array) $strings as $string) { - $this->assertStringContainsString( + $this->assertStringContainsStringIgnoringLineEndings( $string, $output, \sprintf( diff --git a/tests/app/Command/MultilineCommand.php b/tests/app/Command/MultilineCommand.php new file mode 100644 index 0000000..c3884c6 --- /dev/null +++ b/tests/app/Command/MultilineCommand.php @@ -0,0 +1,20 @@ +writeln('first line'); + $this->writeln('second line'); + + return self::SUCCESS; + } +} diff --git a/tests/src/ConsoleTest.php b/tests/src/ConsoleTest.php index 2c79ac9..0114eca 100644 --- a/tests/src/ConsoleTest.php +++ b/tests/src/ConsoleTest.php @@ -20,4 +20,9 @@ final class ConsoleTest extends TestCase $this->assertCommandRegistered('bar'); } + + public function testCommandOutputContainsStringsIgnoringLineEndings(): void + { + $this->assertConsoleCommandOutputContainsStrings('multiline', strings: "first line\r\nsecond line"); + } }