Skip to content

Commit

Permalink
Try
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Feb 19, 2024
1 parent a754fca commit 2047b7b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Report/Reporter/TextReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function display(
$messageLevel = Violation::getLevelAsString($violation->getLevel());
$rows[] = [
new TableCell(sprintf('<comment>%s</comment>', $messageLevel)),
implode("\n", $formattedText),
implode(\PHP_EOL, $formattedText),
];
}

Expand Down
12 changes: 6 additions & 6 deletions tests/BCLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ final class BCLayer
{
public static function assertStringContainsStringIgnoringLineEndings(string $needle, string $haystack, string $message = ''): void
{
// // @phpstan-ignore-next-line
// if (method_exists(Assert::class, 'assertStringContainsStringIgnoringLineEndings')) {
// Assert::assertStringContainsStringIgnoringLineEndings($needle, $haystack, $message);
//
// return;
// }
// // @phpstan-ignore-next-line
// if (method_exists(Assert::class, 'assertStringContainsStringIgnoringLineEndings')) {

Check failure on line 14 in tests/BCLayer.php

View workflow job for this annotation

GitHub Actions / PHPStan

No error to ignore is reported on line 14.
// Assert::assertStringContainsStringIgnoringLineEndings($needle, $haystack, $message);
//
// return;
// }

$needle = strtr($needle, ["\r\n" => "\n", "\r" => "\n"]);
$haystack = strtr($haystack, ["\r\n" => "\n", "\r" => "\n"]);
Expand Down
3 changes: 1 addition & 2 deletions tests/Report/Reporter/CheckstyleReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use TwigCsFixer\Report\Reporter\CheckstyleReporter;
use TwigCsFixer\Report\Violation;
use TwigCsFixer\Report\ViolationId;
use TwigCsFixer\Tests\BCLayer;

final class CheckstyleReporterTest extends TestCase
{
Expand Down Expand Up @@ -83,7 +82,7 @@ public function testDisplayErrors(string $expected, ?string $level, bool $debug)
$textFormatter->display($output, $report, $level, $debug);

$text = $output->fetch();
BCLayer::assertStringContainsStringIgnoringLineEndings($expected, $text);
static::assertSame($expected, rtrim($text));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/Report/Reporter/GithubReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use TwigCsFixer\Report\Reporter\GithubReporter;
use TwigCsFixer\Report\Violation;
use TwigCsFixer\Report\ViolationId;
use TwigCsFixer\Tests\BCLayer;

final class GithubReporterTest extends TestCase
{
Expand Down Expand Up @@ -63,7 +62,7 @@ public function testDisplayErrors(string $expected, ?string $level, bool $debug)
$textFormatter->display($output, $report, $level, $debug);

$text = $output->fetch();
BCLayer::assertStringContainsStringIgnoringLineEndings(str_replace("\n", \PHP_EOL, $expected), $text);
static::assertSame($expected, rtrim($text));
}

/**
Expand Down
5 changes: 2 additions & 3 deletions tests/Report/Reporter/JUnitReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use TwigCsFixer\Report\Reporter\JUnitReporter;
use TwigCsFixer\Report\Violation;
use TwigCsFixer\Report\ViolationId;
use TwigCsFixer\Tests\BCLayer;

final class JUnitReporterTest extends TestCase
{
Expand Down Expand Up @@ -83,7 +82,7 @@ public function testDisplayErrors(string $expected, ?string $level, bool $debug)
$textFormatter->display($output, $report, $level, $debug);

$text = $output->fetch();
BCLayer::assertStringContainsStringIgnoringLineEndings($expected, $text);
static::assertSame($expected, rtrim($text));
}

/**
Expand Down Expand Up @@ -187,6 +186,6 @@ public function testDisplaySuccess(): void
EOD;

$text = $output->fetch();
BCLayer::assertStringContainsStringIgnoringLineEndings($expected, $text);
static::assertSame($expected, rtrim($text));
}
}
8 changes: 4 additions & 4 deletions tests/Report/Reporter/TextReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testDisplayErrors(string $expected, ?string $level, bool $debug)
$textFormatter->display($output, $report, $level, $debug);

$text = $output->fetch();
BCLayer::assertStringContainsStringIgnoringLineEndings($expected, $text);
static::assertStringContainsString($expected, $text);
static::assertStringContainsString('[ERROR]', $text);
}

Expand Down Expand Up @@ -206,7 +206,7 @@ public function testDisplayNotFoundFile(): void
$output = new BufferedOutput();
$textFormatter->display($output, $report, null, false);

BCLayer::assertStringContainsStringIgnoringLineEndings(
static::assertStringContainsString(
sprintf(
<<<EOD
KO %s
Expand All @@ -216,7 +216,7 @@ public function testDisplayNotFoundFile(): void
EOD,
$file
),
$output->fetch()
rtrim($output->fetch())
);
}

Expand All @@ -239,7 +239,7 @@ public function testDisplayBlock(string $expected, int $level): void
$textFormatter->display($output, $report, null, false);

$text = $output->fetch();
BCLayer::assertStringContainsStringIgnoringLineEndings($expected, $text);
static::assertStringContainsString($expected, $text);
}

/**
Expand Down

0 comments on commit 2047b7b

Please sign in to comment.