diff --git a/Process.php b/Process.php index cd84cd44..520794ed 100644 --- a/Process.php +++ b/Process.php @@ -476,7 +476,7 @@ public function getExitCodeText() */ public function isSuccessful() { - return 0 == $this->getExitCode(); + return 0 === $this->getExitCode(); } /** diff --git a/Tests/AbstractProcessTest.php b/Tests/AbstractProcessTest.php index e78374ae..2fc2ea77 100644 --- a/Tests/AbstractProcessTest.php +++ b/Tests/AbstractProcessTest.php @@ -298,6 +298,18 @@ public function testIsSuccessful() $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() { $process = $this->getProcess('php -r "sleep(4);"'); diff --git a/Tests/SigchildDisabledProcessTest.php b/Tests/SigchildDisabledProcessTest.php index 0ec96f47..c82304b5 100644 --- a/Tests/SigchildDisabledProcessTest.php +++ b/Tests/SigchildDisabledProcessTest.php @@ -96,6 +96,14 @@ public function testIsSuccessful() parent::testIsSuccessful(); } + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + */ + public function testIsSuccessfulOnlyAfterTerminated() + { + parent::testIsSuccessfulOnlyAfterTerminated(); + } + /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException */