Skip to content

Commit e724f7a

Browse files
staabmsebastianbergmann
authored andcommitted
Refactor
1 parent 27e3b9c commit e724f7a

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/Runner/Phpt/TestCase.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -350,23 +350,7 @@ private function shouldTestBeSkipped(array $sections, array $settings): bool
350350
$output = $this->runCodeInLocalSandbox($skipIfCode);
351351
}
352352

353-
if (str_contains($output, 'Parse error:')) {
354-
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
355-
sprintf(
356-
'SKIPIF section triggered a parse error: %s',
357-
$output,
358-
),
359-
);
360-
}
361-
362-
if (str_contains($output, 'Fatal error:')) {
363-
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
364-
sprintf(
365-
'SKIPIF section triggered a fatal error: %s',
366-
$output,
367-
),
368-
);
369-
}
353+
$this->triggerWarningOnPhpErrors($output);
370354

371355
if (strncasecmp('skip', ltrim($output), 4) === 0) {
372356
$message = '';
@@ -698,4 +682,25 @@ private function settings(bool $collectCoverage): array
698682

699683
return $settings;
700684
}
685+
686+
private function triggerWarningOnPhpErrors(string $output): void
687+
{
688+
if (str_contains($output, 'Parse error:')) {
689+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
690+
sprintf(
691+
'SKIPIF section triggered a parse error: %s',
692+
$output,
693+
),
694+
);
695+
}
696+
697+
if (str_contains($output, 'Fatal error:')) {
698+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
699+
sprintf(
700+
'SKIPIF section triggered a fatal error: %s',
701+
$output,
702+
),
703+
);
704+
}
705+
}
701706
}

0 commit comments

Comments
 (0)