Skip to content
This repository was archived by the owner on Feb 11, 2019. It is now read-only.
Open
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
5 changes: 4 additions & 1 deletion src/Virtphp/Workers/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,10 @@ protected function installComposer()
);

if ($process->run() != 0) {
throw new \RuntimeException('Could not install Composer.');
$errorMessage = $process->getErrorOutput() ?: $process->getOutput();
$errorMessage = preg_replace('{^#!/usr/bin/env php\s*}', "", $errorMessage);

throw new \RuntimeException('Could not install Composer.' . ($errorMessage ? PHP_EOL.$errorMessage : ''));
}

$this->getFilesystem()->symlink(
Expand Down
2 changes: 1 addition & 1 deletion tests/Virtphp/Test/CompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testCompileGitLogException()
$compiler->expects($this->any())
->method('getProcess')
->will($this->returnCallback(function ($command) {
return new ProcessMock($command, false, -1);
return new ProcessMock($command, false, null, -1);
}));

$compiler->compile($this->testPhar);
Expand Down
15 changes: 11 additions & 4 deletions tests/Virtphp/Test/Mock/ProcessMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
class ProcessMock
{
public $command;
public $output = false;
public $stdout;
public $stderr;
public $runReturn = 0;

public function __construct($command, $output = false, $runReturn = 0)
public function __construct($command, $stdout = null, $stderr = null, $runReturn = 0)
{
$this->command = $command;
$this->output = $output;
$this->stdout = $stdout;
$this->stderr = $stderr;
$this->runReturn = $runReturn;
}

Expand All @@ -21,6 +23,11 @@ public function run()

public function getOutput()
{
return $this->output;
return $this->stdout;
}

public function getErrorOutput()
{
return $this->stderr;
}
}
4 changes: 2 additions & 2 deletions tests/Virtphp/Test/Workers/CreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function testConstructIsUnableToFindPhp()
$creator->expects($this->any())
->method('getProcess')
->will($this->returnCallback(function ($command) {
return new ProcessMock($command, false, 1);
return new ProcessMock($command, false, null, 1);
}));

$creator->__construct($this->input, $this->output, 'myenv', '/foo/bar');
Expand Down Expand Up @@ -320,7 +320,7 @@ public function testSetPhpBinDirWhenBinaryNotValid()
$creator->expects($this->any())
->method('getProcess')
->will($this->returnCallback(function ($command) {
return new ProcessMock($command, false, 1);
return new ProcessMock($command, false, null, 1);
}));

$creator->setPhpBinDir('/some/path/to/php/that/is/not/valid');
Expand Down