[Process] Handle idle timeout and disable output conflict

This commit is contained in:
Romain Neutron 2014-03-14 19:08:20 +01:00
parent b7c158a831
commit 40c08c640e
2 changed files with 30 additions and 0 deletions

View File

@ -418,6 +418,9 @@ class Process
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;
@ -870,6 +873,10 @@ class Process
*/
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;

View File

@ -737,6 +737,29 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$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
*/