bug #10763 [Process] Disable TTY mode on Windows platform (romainneutron)
This PR was merged into the 2.3 branch.
Discussion
----------
[Process] Disable TTY mode on Windows platform
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT
Commits
-------
7942c2a
[Process] Disable TTY mode on Windows platform
This commit is contained in:
commit
544e43f5e2
|
@ -771,9 +771,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;
|
||||
|
|
|
@ -266,7 +266,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();
|
||||
|
@ -281,12 +281,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