Compare lines without involving linebreaks

Fixes tests failing under Windows environments
for any linebreak character differences
This commit is contained in:
Dimitrios Karvounaris
2020-06-02 18:29:50 +02:00
parent f6859eeb3b
commit c05df43217
3 changed files with 18 additions and 29 deletions

View File

@ -1,3 +1,3 @@
<?php <?php
it('example')->assertTrue(true); it('example 1')->assertTrue(true);

View File

@ -1,3 +1,3 @@
<?php <?php
it('example')->assertTrue(true); it('example 2')->assertTrue(true);

View File

@ -11,24 +11,19 @@ $run = function (string $target) {
}; };
test('allows to run a single test', function () use ($run) { test('allows to run a single test', function () use ($run) {
assertStringContainsString(<<<EOF $output = $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php');
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest assertStringContainsString(' PASS Tests\Fixtures\DirectoryWithTests\ExampleTest', $output);
it example assertStringContainsString(' ✓ it example 1', $output);
assertStringContainsString(' Tests: 1 passed', $output);
Tests: 1 passed
EOF, $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'));
}); });
test('allows to run a directory', function () use ($run) { test('allows to run a directory', function () use ($run) {
assertStringContainsString(<<<EOF $output = $run('tests/Fixtures');
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest assertStringContainsString(' PASS Tests\Fixtures\DirectoryWithTests\ExampleTest', $output);
it example assertStringContainsString(' ✓ it example 1', $output);
assertStringContainsString(' PASS Tests\Fixtures\ExampleTest', $output);
PASS Tests\Fixtures\ExampleTest assertStringContainsString(' ✓ it example 2', $output);
it example assertStringContainsString(' Tests: 2 passed', $output);
Tests: 2 passed
EOF, $run('tests/Fixtures'));
}); });
it('has ascii chars (decorated printer)', function () { it('has ascii chars (decorated printer)', function () {
@ -40,12 +35,9 @@ it('has ascii chars (decorated printer)', function () {
$process->run(); $process->run();
$output = $process->getOutput(); $output = $process->getOutput();
assertStringContainsString(<<<EOF assertStringContainsString(" \e[30;42;1m PASS \e[39;49;22m\e[39m Tests\Fixtures\DirectoryWithTests\ExampleTest\e[39m", $output);
\e[30;42;1m PASS \e[39;49;22m\e[39m Tests\Fixtures\DirectoryWithTests\ExampleTest\e[39m assertStringContainsString(" \e[32;1m✓\e[39;22m\e[39m \e[2mit example 1\e[22m\e[39m", $output);
\e[32;1m✓\e[39;22m\e[39m \e[2mit example\e[22m\e[39m assertStringContainsString(" \e[37;1mTests: \e[39;22m\e[32;1m1 passed\e[39;22m", $output);
\e[37;1mTests: \e[39;22m\e[32;1m1 passed\e[39;22m
EOF, $output);
}); });
it('disable decorating printer when colors is set to never', function () { it('disable decorating printer when colors is set to never', function () {
@ -58,10 +50,7 @@ it('disable decorating printer when colors is set to never', function () {
$process->run(); $process->run();
$output = $process->getOutput(); $output = $process->getOutput();
assertStringContainsString(<<<EOF assertStringContainsString(' PASS Tests\Fixtures\DirectoryWithTests\ExampleTest', $output);
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest assertStringContainsString("\e[2mit example 1\e[22m", $output);
\e[2mit example\e[22m assertStringContainsString(' Tests: 1 passed', $output);
Tests: 1 passed
EOF, $output);
}); });