[Console] Split tests for DialogHelper
that tests ask()
method
This commit is contained in:
parent
e6574deb40
commit
7f149ae0aa
@ -54,8 +54,13 @@ class DialogHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
$this->assertEquals('What time is it?', stream_get_contents($output->getStream()));
|
$this->assertEquals('What time is it?', stream_get_contents($output->getStream()));
|
||||||
|
}
|
||||||
|
|
||||||
$bundles = array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle');
|
public function testAskWithAutocomplete()
|
||||||
|
{
|
||||||
|
if (!$this->hasSttyAvailable()) {
|
||||||
|
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||||
|
}
|
||||||
|
|
||||||
// Acm<NEWLINE>
|
// Acm<NEWLINE>
|
||||||
// Ac<BACKSPACE><BACKSPACE>s<TAB>Test<NEWLINE>
|
// Ac<BACKSPACE><BACKSPACE>s<TAB>Test<NEWLINE>
|
||||||
@ -64,18 +69,18 @@ class DialogHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
// <UP ARROW><UP ARROW><UP ARROW><UP ARROW><UP ARROW><TAB><NEWLINE>
|
// <UP ARROW><UP ARROW><UP ARROW><UP ARROW><UP ARROW><TAB><NEWLINE>
|
||||||
// <DOWN ARROW><NEWLINE>
|
// <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\n");
|
$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\n");
|
||||||
|
|
||||||
|
$dialog = new DialogHelper();
|
||||||
$dialog->setInputStream($inputStream);
|
$dialog->setInputStream($inputStream);
|
||||||
|
|
||||||
if ($this->hasSttyAvailable()) {
|
$bundles = array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle');
|
||||||
|
|
||||||
$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('AsseticBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
$this->assertEquals('AsseticBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
||||||
$this->assertEquals('FrameworkBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
$this->assertEquals('FrameworkBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
||||||
$this->assertEquals('SecurityBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
|
$this->assertEquals('SecurityBundle', $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('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));
|
||||||
} else {
|
|
||||||
$this->markTestSkipped();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAskHiddenResponse()
|
public function testAskHiddenResponse()
|
||||||
|
Reference in New Issue
Block a user