minor #12767 [Console] Remove dialog helper usage (blanchonvincent)

This PR was merged into the 2.5 branch.

Discussion
----------

[Console] Remove dialog helper usage

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Because the dialog helper is deprecated, we should use question helper instead.

Commits
-------

844aa54 Remove dialog usage
This commit is contained in:
Fabien Potencier 2014-11-30 11:12:31 +01:00
commit a0703cff9a
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