[Process] Allow non-blocking start with PhpProcess

This commit is contained in:
Pierre Tachoire 2012-12-18 22:02:51 +01:00 committed by Fabien Potencier
parent ab64da5671
commit 2cd43da120
2 changed files with 24 additions and 10 deletions

View File

@ -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);
} }
} }

View 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());
}
}