diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index bc25154a8e..6a5858748a 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -26,8 +26,6 @@ use Symfony\Component\Process\Exception\RuntimeException; */ class PhpProcess extends Process { - private $executableFinder; - /** * Constructor. * @@ -41,9 +39,12 @@ class PhpProcess extends Process */ public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array()) { - parent::__construct(null, $cwd, $env, $script, $timeout, $options); + $executableFinder = new PhpExecutableFinder(); + if (false === $php = $executableFinder->find()) { + $php = null; + } - $this->executableFinder = new PhpExecutableFinder(); + parent::__construct($php, $cwd, $env, $script, $timeout, $options); } /** @@ -62,10 +63,7 @@ class PhpProcess extends Process public function start($callback = null) { if (null === $this->getCommandLine()) { - if (false === $php = $this->executableFinder->find()) { - throw new RuntimeException('Unable to find the PHP executable.'); - } - $this->setCommandLine($php); + throw new RuntimeException('Unable to find the PHP executable.'); } parent::start($callback); diff --git a/src/Symfony/Component/Process/Tests/PhpProcessTest.php b/src/Symfony/Component/Process/Tests/PhpProcessTest.php index df66ad624b..5dc546cc1c 100644 --- a/src/Symfony/Component/Process/Tests/PhpProcessTest.php +++ b/src/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Process\Tests; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpProcess; class PhpProcessTest extends \PHPUnit_Framework_TestCase @@ -26,4 +27,23 @@ PHP $process->wait(); $this->assertEquals($expected, $process->getOutput()); } + + public function testCommandLine() + { + $process = new PhpProcess(<<find(); + + $this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP before start'); + + $process->start(); + $this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start'); + + $process->wait(); + $this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait'); + } }