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