[Process] Disable TTY mode on Windows platform
This commit is contained in:
parent
6518b74995
commit
7942c2a64c
|
@ -774,9 +774,15 @@ class Process
|
|||
* @param bool $tty True to enabled and false to disable
|
||||
*
|
||||
* @return self The current Process instance
|
||||
*
|
||||
* @throws RuntimeException In case the TTY mode is not supported
|
||||
*/
|
||||
public function setTty($tty)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) {
|
||||
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
||||
}
|
||||
|
||||
$this->tty = (bool) $tty;
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -251,7 +251,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"');
|
||||
$process->setTTY(true);
|
||||
$process->setTty(true);
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->wait();
|
||||
|
@ -266,12 +266,24 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||
$process->setTTY(true);
|
||||
$process->setTty(true);
|
||||
$process->run();
|
||||
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testTTYInWindowsEnvironment()
|
||||
{
|
||||
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('This test is for Windows platform only');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||
$process->setTty(false);
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'TTY mode is not supported on Windows platform.');
|
||||
$process->setTty(true);
|
||||
}
|
||||
|
||||
public function testExitCodeTextIsNullWhenExitCodeIsNull()
|
||||
{
|
||||
$process = $this->getProcess('');
|
||||
|
|
Reference in New Issue