8000 minor #12767 [Console] Remove dialog helper usage (blanchonvincent) · symfony/symfony@a0703cf · GitHub
[go: up one dir, main page]

Skip to content

Commit a0703cf

Browse files
committed
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
2 parents 402e183 + 844aa54 commit a0703cf

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
843843

844844
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
845845
$input->setInteractive(false);
846-
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {
847-
$inputStream = $this->getHelperSet()->get('dialog')->getInputStream();
846+
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
847+
$inputStream = $this->getHelperSet()->get('question')->getInputStream();
848848
if (!@posix_isatty($inputStream)) {
849849
$input->setInteractive(false);
850850
}

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,25 @@ public function testSetRunCustomDefaultCommand()
959959

960960
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
961961
}
962+
963+
public function testCanCheckIfTerminalIsInteractive()
964+
{
965+
if (!function_exists('posix_isatty')) {
966+
$this->markTestSkipped('posix_isatty function is required');
967+
}
968+
969+
$application = new CustomDefaultCommandApplication();
970+
$application->setAutoExit(false);
971+
972+
$tester = new ApplicationTester($application);
973+
$tester->run(array('command' => 'help'));
974+
975+
$this->assertTrue($tester->getInput()->isInteractive());
976+
$this->assertFalse($tester->getInput()->hasParameterOption(array('--no-interaction', '-n')));
977+
978+
$inputStream = $application->getHelperSet()->get('question')->getInputStream();
979+
$this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream));
980+
}
962981
}
963982

964983
class CustomApplication extends Application

0 commit comments

Comments
 (0)
0