Skip to content

Commit

Permalink
[Process] Handle idle timeout and disable output conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Mar 14, 2014
1 parent b7c158a commit 40c08c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ public function disableOutput()
if ($this->isRunning()) {
throw new RuntimeException('Disabling output while the process is running is not possible.');
}
if (null !== $this->idleTimeout) {
throw new LogicException('Output can not be disabled while an idle timeout is set.');
}

$this->outputDisabled = true;

Expand Down Expand Up @@ -870,6 +873,10 @@ public function setTimeout($timeout)
*/
public function setIdleTimeout($timeout)
{
if (null !== $timeout && $this->outputDisabled) {
throw new LogicException('Idle timeout can not be set while the output is disabled.');
}

$this->idleTimeout = $this->validateTimeout($timeout);

return $this;
Expand Down
23 changes: 23 additions & 0 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,29 @@ public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
$p->disableOutput();
}

public function testDisableOutputWhileIdleTimeoutIsSet()
{
$process = $this->getProcess('sleep 3');
$process->setIdleTimeout(1);
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Output can not be disabled while an idle timeout is set.');
$process->disableOutput();
}

public function testSetIdleTimeoutWhileOutputIsDisabled()
{
$process = $this->getProcess('sleep 3');
$process->disableOutput();
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Idle timeout can not be set while the output is disabled.');
$process->setIdleTimeout(1);
}

public function testSetNullIdleTimeoutWhileOutputIsDisabled()
{
$process = $this->getProcess('sleep 3');
$process->disableOutput();
$process->setIdleTimeout(null);
}

/**
* @dataProvider provideStartMethods
*/
Expand Down

0 comments on commit 40c08c6

Please sign in to comment.