Updated tests for new QuestionHelper flow
parent
00ca2a91a3
commit
1213d368f6
|
@ -129,20 +129,27 @@ class ConsoleIOTest extends TestCase
|
||||||
{
|
{
|
||||||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
$dialogMock = $this->getMock('Symfony\Component\Console\Helper\DialogHelper');
|
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
|
||||||
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
||||||
|
|
||||||
$dialogMock->expects($this->once())
|
$helperMock
|
||||||
|
->expects($this->once())
|
||||||
->method('ask')
|
->method('ask')
|
||||||
->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'),
|
->with(
|
||||||
$this->equalTo('Why?'),
|
$this->isInstanceOf('Symfony\Component\Console\Input\InputInterface'),
|
||||||
$this->equalTo('default'));
|
$this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'),
|
||||||
$helperMock->expects($this->once())
|
$this->isInstanceOf('Symfony\Component\Console\Question\Question')
|
||||||
->method('get')
|
)
|
||||||
->with($this->equalTo('dialog'))
|
;
|
||||||
->will($this->returnValue($dialogMock));
|
|
||||||
|
|
||||||
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
|
$setMock
|
||||||
|
->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with($this->equalTo('question'))
|
||||||
|
->will($this->returnValue($helperMock))
|
||||||
|
;
|
||||||
|
|
||||||
|
$consoleIO = new ConsoleIO($inputMock, $outputMock, $setMock);
|
||||||
$consoleIO->ask('Why?', 'default');
|
$consoleIO->ask('Why?', 'default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,20 +157,27 @@ class ConsoleIOTest extends TestCase
|
||||||
{
|
{
|
||||||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
$dialogMock = $this->getMock('Symfony\Component\Console\Helper\DialogHelper');
|
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
|
||||||
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
||||||
|
|
||||||
$dialogMock->expects($this->once())
|
$helperMock
|
||||||
->method('askConfirmation')
|
->expects($this->once())
|
||||||
->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'),
|
->method('ask')
|
||||||
$this->equalTo('Why?'),
|
->with(
|
||||||
$this->equalTo('default'));
|
$this->isInstanceOf('Symfony\Component\Console\Input\InputInterface'),
|
||||||
$helperMock->expects($this->once())
|
$this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'),
|
||||||
|
$this->isInstanceOf('Symfony\Component\Console\Question\ConfirmationQuestion')
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
$setMock
|
||||||
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with($this->equalTo('dialog'))
|
->with($this->equalTo('question'))
|
||||||
->will($this->returnValue($dialogMock));
|
->will($this->returnValue($helperMock))
|
||||||
|
;
|
||||||
|
|
||||||
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
|
$consoleIO = new ConsoleIO($inputMock, $outputMock, $setMock);
|
||||||
$consoleIO->askConfirmation('Why?', 'default');
|
$consoleIO->askConfirmation('Why?', 'default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,22 +185,27 @@ class ConsoleIOTest extends TestCase
|
||||||
{
|
{
|
||||||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
$dialogMock = $this->getMock('Symfony\Component\Console\Helper\DialogHelper');
|
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
|
||||||
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
||||||
|
|
||||||
$dialogMock->expects($this->once())
|
$helperMock
|
||||||
->method('askAndValidate')
|
->expects($this->once())
|
||||||
->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'),
|
->method('ask')
|
||||||
$this->equalTo('Why?'),
|
->with(
|
||||||
$this->equalTo('validator'),
|
$this->isInstanceOf('Symfony\Component\Console\Input\InputInterface'),
|
||||||
$this->equalTo(10),
|
$this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'),
|
||||||
$this->equalTo('default'));
|
$this->isInstanceOf('Symfony\Component\Console\Question\Question')
|
||||||
$helperMock->expects($this->once())
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
$setMock
|
||||||
|
->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with($this->equalTo('dialog'))
|
->with($this->equalTo('question'))
|
||||||
->will($this->returnValue($dialogMock));
|
->will($this->returnValue($helperMock))
|
||||||
|
;
|
||||||
|
|
||||||
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
|
$consoleIO = new ConsoleIO($inputMock, $outputMock, $setMock);
|
||||||
$consoleIO->askAndValidate('Why?', 'validator', 10, 'default');
|
$consoleIO->askAndValidate('Why?', 'validator', 10, 'default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue