[2.3][Process] Fixed PhpProcess::getCommandLine() result
This commit is contained in:
parent
e759bc3836
commit
d0f1d3236c
@ -26,8 +26,6 @@ use Symfony\Component\Process\Exception\RuntimeException;
|
|||||||
*/
|
*/
|
||||||
class PhpProcess extends Process
|
class PhpProcess extends Process
|
||||||
{
|
{
|
||||||
private $executableFinder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -41,9 +39,12 @@ class PhpProcess extends Process
|
|||||||
*/
|
*/
|
||||||
public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array())
|
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)
|
public function start($callback = null)
|
||||||
{
|
{
|
||||||
if (null === $this->getCommandLine()) {
|
if (null === $this->getCommandLine()) {
|
||||||
if (false === $php = $this->executableFinder->find()) {
|
throw new RuntimeException('Unable to find the PHP executable.');
|
||||||
throw new RuntimeException('Unable to find the PHP executable.');
|
|
||||||
}
|
|
||||||
$this->setCommandLine($php);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::start($callback);
|
parent::start($callback);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Process\Tests;
|
namespace Symfony\Component\Process\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
use Symfony\Component\Process\PhpProcess;
|
use Symfony\Component\Process\PhpProcess;
|
||||||
|
|
||||||
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -26,4 +27,23 @@ PHP
|
|||||||
$process->wait();
|
$process->wait();
|
||||||
$this->assertEquals($expected, $process->getOutput());
|
$this->assertEquals($expected, $process->getOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCommandLine()
|
||||||
|
{
|
||||||
|
$process = new PhpProcess(<<<PHP
|
||||||
|
<?php echo 'foobar';
|
||||||
|
PHP
|
||||||
|
);
|
||||||
|
|
||||||
|
$f = new PhpExecutableFinder();
|
||||||
|
$commandLine = $f->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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user