Skip to content

Commit

Permalink
merged branch tgabi333/2.2 (PR #8815)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.2 branch.

Discussion
----------

[Process] fix for Process:isSuccessful()

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| Fixed tickets | []
| License       | MIT
| Doc PR        | []

This is a rebase of symfony/symfony#8801

If you call isSuccessful() on a running process you would get true because of 0 == null. I think that is not the expected behavior and that is not what phpdoc @return block said so.

Commits
-------

262879d fix for Process:isSuccessful()
  • Loading branch information
fabpot committed Aug 21, 2013
2 parents 0ed724e + 0f58865 commit e4a89b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public function getExitCodeText()
*/
public function isSuccessful()
{
return 0 == $this->getExitCode();
return 0 === $this->getExitCode();
}

/**
Expand Down
12 changes: 12 additions & 0 deletions Tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);"');
Expand Down
8 changes: 8 additions & 0 deletions Tests/SigchildDisabledProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit e4a89b7

Please sign in to comment.