public function testCommandFromApplication() { $application = new Application(); $application->setAutoExit(false); $callable = function ($input, $output) { $output->writeln('foo'); }; $command = new Command('foo', $callable); $application->add($command); $tester = new CommandTester($application->find('foo')); $result = $tester->execute(array()); $this->assertInstanceOf('Danack\\Console\\Command\\ParsedCommand', $result); }
public function testSetRunCustomDefaultCommand() { $command = new \FooCommand(); $application = new Application(); $application->setAutoExit(false); $application->add($command); $application->setDefaultCommand($command->getName()); $tester = new ApplicationTester($application); $parsedCommand = $tester->run(array()); $provider = new Provider(); $provider->execute($parsedCommand->getCallable(), []); $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); $application = new CustomDefaultCommandApplication(); $application->setAutoExit(false); $tester = new ApplicationTester($application); $parsedCommand = $tester->run(array()); $provider->execute($parsedCommand->getCallable(), []); $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); }