Skip to content
This repository has been archived by the owner on Feb 11, 2019. It is now read-only.

Commit

Permalink
Merge 1a65d8b into d0d1de1
Browse files Browse the repository at this point in the history
  • Loading branch information
philsturgeon committed Oct 2, 2014
2 parents d0d1de1 + 1a65d8b commit 42027a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/Virtphp/Workers/Creator.php
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
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
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
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

0 comments on commit 42027a4

Please sign in to comment.