[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
|
* @param bool $tty True to enabled and false to disable
|
||||||
*
|
*
|
||||||
* @return self The current Process instance
|
* @return self The current Process instance
|
||||||
|
*
|
||||||
|
* @throws RuntimeException In case the TTY mode is not supported
|
||||||
*/
|
*/
|
||||||
public function setTty($tty)
|
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;
|
$this->tty = (bool) $tty;
|
||||||
|
|
||||||
return $this;
|
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 = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"');
|
||||||
$process->setTTY(true);
|
$process->setTty(true);
|
||||||
$process->start();
|
$process->start();
|
||||||
$this->assertTrue($process->isRunning());
|
$this->assertTrue($process->isRunning());
|
||||||
$process->wait();
|
$process->wait();
|
||||||
@ -266,12 +266,24 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||||
$process->setTTY(true);
|
$process->setTty(true);
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
$this->assertTrue($process->isSuccessful());
|
$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()
|
public function testExitCodeTextIsNullWhenExitCodeIsNull()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('');
|
$process = $this->getProcess('');
|
||||||
|
Reference in New Issue
Block a user