ask() public method

public ask ( $question, $default = null )
示例#1
0
 public function testAsk()
 {
     $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');
     $dialogMock->expects($this->once())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->equalTo('Is valid?'), $this->equalTo('default'));
     $helperMock->expects($this->once())->method('get')->with($this->equalTo('dialog'))->will($this->returnValue($dialogMock));
     $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
     $consoleIO->ask('Is valid?', 'default');
 }
示例#2
0
 public function testAsk()
 {
     $inputMock = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputInterface')->getMock();
     $outputMock = $this->getMockBuilder('Symfony\\Component\\Console\\Output\\OutputInterface')->getMock();
     $questionHelperMock = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\QuestionHelper')->getMock();
     $helperMock = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\HelperSet')->getMock();
     $question = new \Symfony\Component\Console\Question\Question('Your name?', '');
     $questionHelperMock->expects($this->once())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $question);
     $helperMock->expects($this->once())->method('get')->with($this->equalTo('question'))->will($this->returnValue($questionHelperMock));
     $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
     $consoleIO->ask('Your name?', '');
 }
示例#3
0
 public function testAsk()
 {
     $this->command->setCode(function (InputInterface $input, OutputInterface $output) use(&$isDecorated) {
         $io = new ConsoleIO($input, $output);
         $result = $io->ask('what is your name?', 'Yo! Symfony');
         $this->assertEquals('Yo! Symfony', $result);
     });
     $this->tester->execute([], ['interactive' => false, 'decorated' => false]);
 }