Remove dialog usage

This commit is contained in:
blanchonvincent 2014-11-30 09:03:32 +01:00
parent 402e18321e
commit 844aa54aa2
2 changed files with 21 additions and 2 deletions

View File

@ -843,8 +843,8 @@ class Application
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
$input->setInteractive(false);
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {
$inputStream = $this->getHelperSet()->get('dialog')->getInputStream();
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
$inputStream = $this->getHelperSet()->get('question')->getInputStream();
if (!@posix_isatty($inputStream)) {
$input->setInteractive(false);
}

View File

@ -959,6 +959,25 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
}
public function testCanCheckIfTerminalIsInteractive()
{
if (!function_exists('posix_isatty')) {
$this->markTestSkipped('posix_isatty function is required');
}
$application = new CustomDefaultCommandApplication();
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'help'));
$this->assertTrue($tester->getInput()->isInteractive());
$this->assertFalse($tester->getInput()->hasParameterOption(array('--no-interaction', '-n')));
$inputStream = $application->getHelperSet()->get('question')->getInputStream();
$this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream));
}
}
class CustomApplication extends Application