From 0f58865d7b1838575a61ac4a9ba24a35c37f2047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3th=20G=C3=A1bor?= Date: Wed, 21 Aug 2013 16:50:47 +0200 Subject: [PATCH] fix for Process:isSuccessful() --- Process.php | 2 +- Tests/AbstractProcessTest.php | 12 ++++++++++++ Tests/SigchildDisabledProcessTest.php | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Process.php b/Process.php index 91634297..855015bc 100644 --- a/Process.php +++ b/Process.php @@ -489,7 +489,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 1021746e..76ea2a64 100644 --- a/Tests/AbstractProcessTest.php +++ b/Tests/AbstractProcessTest.php @@ -277,6 +277,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 1e4dc1d0..42da0a78 100644 --- a/Tests/SigchildDisabledProcessTest.php +++ b/Tests/SigchildDisabledProcessTest.php @@ -80,6 +80,14 @@ public function testIsSuccessful() parent::testIsSuccessful(); } + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + */ + public function testIsSuccessfulOnlyAfterTerminated() + { + parent::testIsSuccessfulOnlyAfterTerminated(); + } + /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException */