command = $this->getMockBuilder('PHPCI\\Command\\CreateAdminCommand') ->setConstructorArgs(array($this->getMock('PHPCI\\Service\\UserService', array(), array(), '', false))) ->setMethods(array('reloadConfig')) ->getMock() ; $this->dialog = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\DialogHelper') ->setMethods(array( 'ask', 'askAndValidate', 'askHiddenResponse', )) ->getMock() ; $this->application = new Application(); } /** * @return CommandTester */ protected function getCommandTester() { $this->application->getHelperSet()->set($this->dialog, 'dialog'); $this->application->add($this->command); $command = $this->application->find('phpci:create-admin'); $commandTester = new CommandTester($command); return $commandTester; } public function testExecute() { $this->dialog->expects($this->at(0))->method('askAndValidate')->will($this->returnValue('test@example.com')); $this->dialog->expects($this->at(1))->method('ask')->will($this->returnValue('A name')); $this->dialog->expects($this->at(2))->method('askHiddenResponse')->will($this->returnValue('foobar123')); $commandTester = $this->getCommandTester(); $commandTester->execute(array()); $this->assertEquals('User account created!' . PHP_EOL, $commandTester->getDisplay()); } }