[Process] Allow non-blocking start with PhpProcess
This commit is contained in:
parent
ab64da5671
commit
2cd43da120
@ -55,16 +55,9 @@ class PhpProcess extends Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the process.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param Closure|string|array $callback A PHP callback to run whenever there is some
|
|
||||||
* output available on STDOUT or STDERR
|
|
||||||
*
|
|
||||||
* @return integer The exit status code
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
*/
|
||||||
public function run($callback = null)
|
public function start($callback = null)
|
||||||
{
|
{
|
||||||
if (null === $this->getCommandLine()) {
|
if (null === $this->getCommandLine()) {
|
||||||
if (false === $php = $this->executableFinder->find()) {
|
if (false === $php = $this->executableFinder->find()) {
|
||||||
@ -73,6 +66,6 @@ class PhpProcess extends Process
|
|||||||
$this->setCommandLine($php);
|
$this->setCommandLine($php);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::run($callback);
|
return parent::start($callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
src/Symfony/Component/Process/Tests/PhpProcessTest.php
Normal file
21
src/Symfony/Component/Process/Tests/PhpProcessTest.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symfony\Component\Process\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\PhpProcess;
|
||||||
|
|
||||||
|
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testNonBlockingWorks()
|
||||||
|
{
|
||||||
|
$expected = 'hello world!';
|
||||||
|
$process = new PhpProcess(<<<PHP
|
||||||
|
<?php echo '$expected';
|
||||||
|
PHP
|
||||||
|
);
|
||||||
|
$process->start();
|
||||||
|
$process->wait();
|
||||||
|
$this->assertEquals($expected, $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user