merged branch kipit/ticket_7549 (PR #7623)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #7623). Discussion ---------- [Console] fixed handling of "0" input on ask | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7549 | License | MIT | Doc PR | Commits ------- 18a9eaf [Console] fixed handling of "0" input on ask
This commit is contained in:
commit
6c05afa92d
@ -102,7 +102,9 @@ class DialogHelper extends Helper
|
|||||||
$output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
|
$output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
|
||||||
|
|
||||||
// Read a keypress
|
// Read a keypress
|
||||||
while ($c = fread($inputStream, 1)) {
|
while (!feof($inputStream)) {
|
||||||
|
$c = fread($inputStream, 1);
|
||||||
|
|
||||||
// Backspace Character
|
// Backspace Character
|
||||||
if ("\177" === $c) {
|
if ("\177" === $c) {
|
||||||
if (0 === $numMatches && 0 !== $i) {
|
if (0 === $numMatches && 0 !== $i) {
|
||||||
|
@ -69,7 +69,8 @@ class DialogHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
// <UP ARROW><UP ARROW><UP ARROW><UP ARROW><UP ARROW><TAB>Test<NEWLINE>
|
// <UP ARROW><UP ARROW><UP ARROW><UP ARROW><UP ARROW><TAB>Test<NEWLINE>
|
||||||
// <DOWN ARROW><NEWLINE>
|
// <DOWN ARROW><NEWLINE>
|
||||||
// S<BACKSPACE><BACKSPACE><DOWN ARROW><DOWN ARROW><NEWLINE>
|
// S<BACKSPACE><BACKSPACE><DOWN ARROW><DOWN ARROW><NEWLINE>
|
||||||
$inputStream = $this->getInputStream("Acm\nAc\177\177s\tTest\n\n\033[A\033[A\n\033[A\033[A\033[A\033[A\033[A\tTest\n\033[B\nS\177\177\033[B\033[B\n");
|
// F00<BACKSPACE><BACKSPACE>oo<TAB><NEWLINE>
|
||||||
|
$inputStream = $this->getInputStream("Acm\nAc\177\177s\tTest\n\n\033[A\033[A\n\033[A\033[A\033[A\033[A\033[A\tTest\n\033[B\nS\177\177\033[B\033[B\nF00\177\177oo\t\n");
|
||||||
|
|
||||||
$dialog = new DialogHelper();
|
$dialog = new DialogHelper();
|
||||||
$dialog->setInputStream($inputStream);
|
$dialog->setInputStream($inputStream);
|
||||||
@ -83,6 +84,7 @@ class DialogHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('FooBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
$this->assertEquals('FooBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
||||||
$this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
$this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
||||||
$this->assertEquals('AsseticBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
$this->assertEquals('AsseticBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
||||||
|
$this->assertEquals('FooBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAskHiddenResponse()
|
public function testAskHiddenResponse()
|
||||||
|
Reference in New Issue
Block a user