示例#1
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');
 }
示例#2
0
 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);
 }
示例#3
0
    public function testExecuteListsCommandsWithNamespaceArgument()
    {
        require_once realpath(__DIR__ . '/../Fixtures/FooCommand.php');
        $application = new Application();
        $application->add(new \FooCommand());
        $commandTester = new CommandTester($command = $application->get('list'));
        $parsedCommand = $commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true));
        /** @var $parsedCommand ParsedCommand */
        $injector = new \Auryn\Provider();
        $injector->execute($parsedCommand->getCallable());
        $output = <<<EOF
foo:bar   The foo:bar command

EOF;
        $this->assertEquals($output, $commandTester->getDisplay(true));
    }
示例#4
0
 public function testAsXml()
 {
     $command = new \TestCommand();
     $command->setApplication(new Application());
     $tester = new CommandTester($command);
     $tester->execute(array('command' => $command->getName()));
     $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command');
 }