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:
commit
a0703cff9a
@ -843,8 +843,8 @@ class Application
|
|||||||
|
|
||||||
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
|
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
|
||||||
$input->setInteractive(false);
|
$input->setInteractive(false);
|
||||||
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {
|
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
|
||||||
$inputStream = $this->getHelperSet()->get('dialog')->getInputStream();
|
$inputStream = $this->getHelperSet()->get('question')->getInputStream();
|
||||||
if (!@posix_isatty($inputStream)) {
|
if (!@posix_isatty($inputStream)) {
|
||||||
$input->setInteractive(false);
|
$input->setInteractive(false);
|
||||||
}
|
}
|
||||||
|
@ -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');
|
$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
|
class CustomApplication extends Application
|
||||||
|
Reference in New Issue
Block a user