fix: ignore line endings in scaffolder output assertions

This commit is contained in:
dualfroz committed 2026-10-03 01:50:30 +02:00
1 parent 362e25d279
commit 816d6d3cd4
2 files changed
+53 -2

No files matched your search

+10 -2
View File
@@ -36,7 +36,11 @@ trait InteractsWithScaffolder
}); });
foreach ($expectedOutputStrings as $expected) { foreach ($expectedOutputStrings as $expected) {
$this->assertStringContainsString($expected, $output, 'Output does not contain expected string.'); $this->assertStringContainsStringIgnoringLineEndings(
$expected,
$output,
'Output does not contain expected string.',
);
} }
} }
@@ -68,7 +72,11 @@ trait InteractsWithScaffolder
}); });
foreach ($expectedOutputStrings as $expected) { foreach ($expectedOutputStrings as $expected) {
$this->assertStringContainsString($expected, $output, 'Output does not contain expected string.'); $this->assertStringContainsStringIgnoringLineEndings(
$expected,
$output,
'Output does not contain expected string.',
);
} }
} }
+43
View File
@@ -92,6 +92,49 @@ PHP,
); );
} }
public function testCommandSameOutputStringsIgnoreLineEndings(): void
{
$this->assertScaffolderCommandSame(
'create:filter',
[
'name' => 'Test',
],
expected: <<<'PHP'
<?php
declare(strict_types=1);
namespace Spiral\Testing\Filter;
use Spiral\Filters\Model\Filter;
final class TestFilter extends Filter
{
}
PHP,
expectedOutputStrings: [
"Next steps:\r\n1. Read more about Filter Objects in the documentation",
],
);
}
public function testCommandContainsOutputStringsIgnoreLineEndings(): void
{
$this->assertScaffolderCommandContains(
'create:filter',
[
'name' => 'Test',
],
expectedStrings: [
'final class TestFilter extends Filter',
],
expectedOutputStrings: [
"Next steps:\r\n1. Read more about Filter Objects in the documentation",
],
);
}
public function testAfterTestFilesShoulBeRestored(): void public function testAfterTestFilesShoulBeRestored(): void
{ {
$files = $this->mockContainer(FilesInterface::class); $files = $this->mockContainer(FilesInterface::class);