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 e116f24 commit 6fd88cc
Show file tree
Hide file tree
Showing 4 changed files with 940 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test-os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
dependency-versions: highest
composer-options: --prefer-dist --prefer-stable

- name: Test 1
run: rm vendor/symfony/console/Helper/Table.php

- name: Test 2
run: mv tmp/Table.php vendor/symfony/console/Helper/Table.php

- name: Run tests with PHPUnit
run: vendor/bin/phpunit

Expand Down
10 changes: 5 additions & 5 deletions src/Report/Reporter/CheckstyleReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public function display(
?string $level,
bool $debug
): void {
$text = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$text = '<?xml version="1.0" encoding="UTF-8"?>'.\PHP_EOL;

$text .= '<checkstyle>'."\n";
$text .= '<checkstyle>'.\PHP_EOL;

foreach ($report->getFiles() as $file) {
$fileViolations = $report->getFileViolations($file, $level);
if (0 === \count($fileViolations)) {
continue;
}

$text .= sprintf(' <file name="%s">', $this->xmlEncode($file))."\n";
$text .= sprintf(' <file name="%s">', $this->xmlEncode($file)).\PHP_EOL;
foreach ($fileViolations as $violation) {
$line = (string) $violation->getLine();
$linePosition = (string) $violation->getLinePosition();
Expand All @@ -46,9 +46,9 @@ public function display(
if (null !== $ruleName) {
$text .= ' source="'.$ruleName.'"';
}
$text .= '/>'."\n";
$text .= '/>'.\PHP_EOL;
}
$text .= ' </file>'."\n";
$text .= ' </file>'.\PHP_EOL;
}

$text .= '</checkstyle>';
Expand Down
14 changes: 7 additions & 7 deletions src/Report/Reporter/JUnitReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public function display(
$violations = $report->getViolations($level);
$count = \count($violations);

$text = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$text .= '<testsuites>'."\n";
$text = '<?xml version="1.0" encoding="UTF-8"?>'.\PHP_EOL;
$text .= '<testsuites>'.\PHP_EOL;
$text .= ' '.sprintf(
'<testsuite name="Twig CS Fixer" tests="%d" failures="%d">',
max($count, 1),
$count
)."\n";
).\PHP_EOL;

if ($count > 0) {
foreach ($violations as $violation) {
Expand All @@ -41,23 +41,23 @@ public function display(
$text .= $this->createTestCase('All OK');
}

$text .= ' </testsuite>'."\n";
$text .= ' </testsuite>'.\PHP_EOL;
$text .= '</testsuites>';

$output->writeln($text);
}

private function createTestCase(string $name, string $type = '', ?string $message = null): string
{
$result = ' '.sprintf('<testcase name="%s">', $this->xmlEncode($name))."\n";
$result = ' '.sprintf('<testcase name="%s">', $this->xmlEncode($name)).\PHP_EOL;

if (null !== $message) {
$result .= ' '
.sprintf('<failure type="%s" message="%s" />', $this->xmlEncode($type), $this->xmlEncode($message))
."\n";
.\PHP_EOL;
}

$result .= ' </testcase>'."\n";
$result .= ' </testcase>'.\PHP_EOL;

return $result;
}
Expand Down
Loading

0 comments on commit 6fd88cc

Please sign in to comment.