fix for Process:isSuccessful()

This commit is contained in:
Tóth Gábor 2013-08-21 16:50:47 +02:00
parent 98e1795915
commit 262879d8b5
3 changed files with 21 additions and 1 deletions

View File

@ -489,7 +489,7 @@ class Process
*/ */
public function isSuccessful() public function isSuccessful()
{ {
return 0 == $this->getExitCode(); return 0 === $this->getExitCode();
} }
/** /**

View File

@ -277,6 +277,18 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($process->isSuccessful()); $this->assertTrue($process->isSuccessful());
} }
public function testIsSuccessfulOnlyAfterTerminated()
{
$process = $this->getProcess('sleep 1');
$process->start();
while ($process->isRunning()) {
$this->assertFalse($process->isSuccessful());
usleep(300000);
}
$this->assertTrue($process->isSuccessful());
}
public function testIsNotSuccessful() public function testIsNotSuccessful()
{ {
$process = $this->getProcess('php -r "sleep(4);"'); $process = $this->getProcess('php -r "sleep(4);"');

View File

@ -80,6 +80,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
parent::testIsSuccessful(); parent::testIsSuccessful();
} }
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testIsSuccessfulOnlyAfterTerminated()
{
parent::testIsSuccessfulOnlyAfterTerminated();
}
/** /**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException * @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/ */