From 262879d8b50aed587d3f80edd69e72441651f5d9 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() --- src/Symfony/Component/Process/Process.php | 2 +- .../Component/Process/Tests/AbstractProcessTest.php | 12 ++++++++++++ .../Process/Tests/SigchildDisabledProcessTest.php | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 91634297d8..855015bc6d 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -489,7 +489,7 @@ class Process */ public function isSuccessful() { - return 0 == $this->getExitCode(); + return 0 === $this->getExitCode(); } /** diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 1021746e76..76ea2a64f2 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -277,6 +277,18 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $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/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 1e4dc1d0a2..42da0a784c 100644 --- a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -80,6 +80,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest parent::testIsSuccessful(); } + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + */ + public function testIsSuccessfulOnlyAfterTerminated() + { + parent::testIsSuccessfulOnlyAfterTerminated(); + } + /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException */