Skip to content

Commit beacf08

Browse files
Add GitLab output format support to CheckCommand
Introduced support for the GitLab-specific output format in the Check command and its end-to-end test suite. Modified the condition in the Check command to handle the GitLab format and added a corresponding test case to verify functionality for outputs with no errors.
1 parent 23b58a5 commit beacf08

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/CLI/Command/Check.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private function printNoViolationsDetectedMessage(OutputInterface $output, bool
285285
{
286286
if (!$onlyErrors) {
287287
$output->writeln('<info>NO VIOLATIONS DETECTED!</info>');
288-
} elseif (Printer::FORMAT_JSON === $format) {
288+
} elseif (Printer::FORMAT_JSON === $format || Printer::FORMAT_GITLAB === $format) {
289289
$output->writeln('<info>[]</info>');
290290
}
291291
}

tests/E2E/Cli/CheckCommandTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ public function test_gitlab_format_output(): void
221221
$this->assertSame(1, $decodedResult[0]['lines']['begin']);
222222
}
223223

224+
public function test_gitlab_format_output_no_errors(): void
225+
{
226+
$configFilePath = __DIR__.'/../_fixtures/configMvcWithoutErrors.php';
227+
228+
$cmdTester = $this->runCheck($configFilePath, null, null, false, false, false, 'gitlab');
229+
230+
$this->assertCheckHasSuccess($cmdTester);
231+
232+
$display = $cmdTester->getDisplay();
233+
234+
$this->assertJson($display);
235+
236+
$json = json_decode($display, true);
237+
$this->assertCount(0, $json);
238+
}
239+
224240
protected function runCheck(
225241
$configFilePath = null,
226242
?bool $stopOnFailure = null,

0 commit comments

Comments
 (0)