fix: ignore line endings in console output assertions
This commit is contained in:
1 parent
e8fb94b682
commit
50c16b7998
3 files changed
+26
-1
No files matched your search
@@ -25,7 +25,7 @@ trait InteractsWithConsole
|
|||||||
$output = $this->runCommand($command, $args);
|
$output = $this->runCommand($command, $args);
|
||||||
|
|
||||||
foreach ((array) $strings as $string) {
|
foreach ((array) $strings as $string) {
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsStringIgnoringLineEndings(
|
||||||
$string,
|
$string,
|
||||||
$output,
|
$output,
|
||||||
\sprintf(
|
\sprintf(
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Spiral\Testing\Tests\App\Command;
|
||||||
|
|
||||||
|
use Spiral\Console\Command;
|
||||||
|
|
||||||
|
final class MultilineCommand extends Command
|
||||||
|
{
|
||||||
|
protected const NAME = 'multiline';
|
||||||
|
|
||||||
|
public function perform(): int
|
||||||
|
{
|
||||||
|
$this->writeln('first line');
|
||||||
|
$this->writeln('second line');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,4 +20,9 @@ final class ConsoleTest extends TestCase
|
|||||||
|
|
||||||
$this->assertCommandRegistered('bar');
|
$this->assertCommandRegistered('bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCommandOutputContainsStringsIgnoringLineEndings(): void
|
||||||
|
{
|
||||||
|
$this->assertConsoleCommandOutputContainsStrings('multiline', strings: "first line\r\nsecond line");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user