Skip to content

Commit

Permalink
merged branch cup-of-giraf/phpprocess_allow_non_blocking (PR #6411)
Browse files Browse the repository at this point in the history
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: -
  • Loading branch information
fabpot committed Dec 19, 2012
2 parents ab64da5 + 2cd43da commit 055daa9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Symfony/Component/Process/PhpProcess.php
Expand Up @@ -55,16 +55,9 @@ public function setPhpBinary($php)
}

/**
* 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()) {
Expand All @@ -73,6 +66,6 @@ public function run($callback = null)
$this->setCommandLine($php);
}

return parent::run($callback);
return parent::start($callback);
}
}
21 changes: 21 additions & 0 deletions src/Symfony/Component/Process/Tests/PhpProcessTest.php
@@ -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());
}
}

0 comments on commit 055daa9

Please sign in to comment.