Example #1
0
 public function testGetDisplay()
 {
     $output = $this->tester->getOutput();
     $this->provider->alias('Danack\\Console\\Output\\Output', get_class($output));
     $this->provider->share($output);
     $callable = $this->parsedCommand->getCallable();
     $this->provider->execute($callable, []);
     $this->assertEquals('foo' . PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution');
 }
Example #2
0
 public function testExecuteForApplicationCommandWithXmlOption()
 {
     $application = new Application();
     $commandTester = new CommandTester($application->get('help'));
     $parsedCommand = $commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
     $provider = new Provider();
     $provider->execute($parsedCommand->getCallable(), []);
     $this->assertRegExp('/list \\[--xml\\] \\[--raw\\] \\[--format="\\.\\.\\."\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
     $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
 }
Example #3
0
    public function testExecuteListsCommandsWithRawOption()
    {
        $application = new Application();
        $commandTester = new CommandTester($command = $application->get('list'));
        $parsedCommand = $commandTester->execute(array('command' => $command->getName(), '--raw' => true));
        $provider = new Provider();
        $provider->execute($parsedCommand->getCallable(), []);
        $output = <<<EOF
help   Displays help for a command
list   Lists commands

EOF;
        $this->assertEquals($output, $commandTester->getDisplay(true));
    }
Example #4
0
 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');
 }