Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spec/Task/Php7ccSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function it_runs_the_suite(ProcessBuilder $processBuilder, Process $process, Con

$process->run()->shouldBeCalled();
$process->isSuccessful()->willReturn(true);
$process->getOutput()->willReturn('');

$context->getFiles()->willReturn(new FilesCollection([
new SplFileInfo('test.php', '.', 'test.php')
Expand All @@ -90,8 +91,17 @@ function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder
$processBuilder->createArgumentsForCommand('php7cc')->willReturn($arguments);
$processBuilder->buildProcess($arguments)->willReturn($process);

$failedOutput = <<<'OUTPUT'
File: /path/to/bad.php
> Line 3: Removed argument $is_dst used for function "mktime"
mktime(5, 5, 5, 5, 5, 2000, -1);

Checked 2 files in 0.040 second
OUTPUT;

$process->run()->shouldBeCalled();
$process->isSuccessful()->willReturn(false);
$process->getOutput()->willReturn($failedOutput);

$context->getFiles()->willReturn(new FilesCollection([
new SplFileInfo('test.php', '.', 'test.php')
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Php7cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function run(ContextInterface $context)
$process = $this->processBuilder->buildProcess($arguments);
$process->run();

if (!$process->isSuccessful()) {
if (preg_match('/^File: /m', $process->getOutput()) === 1) {
return TaskResult::createFailed($this, $context, $this->formatter->format($process));
}

Expand Down