merged branch cup-of-giraf/phpprocess_allow_non_blocking (PR #6411)

This PR was squashed before being merged into the 2.1 branch (closes #6411).

Commits
-------

2cd43da [Process] Allow non-blocking start with PhpProcess

Discussion
----------

[Process] Allow non-blocking start with PhpProcess

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #6410
Todo: -
License of the code: MIT
Documentation PR: -
This commit is contained in:
Fabien Potencier 2012-12-19 14:27:19 +01:00
commit 055daa99ac
2 changed files with 24 additions and 10 deletions

View File

@ -55,16 +55,9 @@ class PhpProcess extends Process
}
/**
* Runs the process.
*
* @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
* {@inheritdoc}
*/
public function run($callback = null)
public function start($callback = null)
{
if (null === $this->getCommandLine()) {
if (false === $php = $this->executableFinder->find()) {
@ -73,6 +66,6 @@ class PhpProcess extends Process
$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());
}
}