public function testDoNotRethrowParseErrorIfLenient() { $config = ApplicationConfig::create()->beginCommand('package')->enableLenientArgsParsing()->end(); $application = new ConsoleApplication($config); $command = $application->getCommand('package'); $rawArgs = new StringArgs('package --foo'); $resolvedCommand = $this->resolver->resolveCommand($rawArgs, $application, true); $args = new Args($command->getArgsFormat(), $rawArgs); $this->assertSame($command, $resolvedCommand->getCommand()); $this->assertEquals($args, $resolvedCommand->getArgs()); }
public function testCreate() { $config = ApplicationConfig::create()->setName('test-bin')->setDisplayName('Test Name')->setVersion('1.2.3')->setHelperSet($helperSet = new HelperSet())->beginCommand('command')->end(); $application = new ConsoleApplication($config); $adapter = new ApplicationAdapter($application); $this->assertSame('Test Name', $adapter->getName()); $this->assertSame('1.2.3', $adapter->getVersion()); $this->assertSame('<info>Test Name</info> version <comment>1.2.3</comment>', $adapter->getLongVersion()); $this->assertSame('<info>Test Name</info> version <comment>1.2.3</comment>', $adapter->getHelp()); $this->assertSame($helperSet, $adapter->getHelperSet()); $this->assertSame(array(), $adapter->getNamespaces()); $this->assertEquals(new ArgsFormatInputDefinition($application->getGlobalArgsFormat()), $adapter->getDefinition()); $commandAdapter = new CommandAdapter($application->getCommand('command'), $adapter); $commandAdapter->setApplication($adapter); $commandAdapter->setHelperSet($helperSet); $this->assertEquals($commandAdapter, $adapter->get('command')); }
public function testRenderOptionCommandWithPreferredLongName() { $config = ApplicationConfig::create()->setName('test-bin')->beginCommand('command')->beginOptionCommand('add', 'a')->setDescription('Description of "add"')->setPreferLongName()->end()->end(); $application = new ConsoleApplication($config); $help = new CommandHelp($application->getCommand('command')); $help->render($this->io); $expected = <<<'EOF' USAGE test-bin command or: test-bin command --add COMMANDS --add (-a) Description of "add" EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
/** * @expectedException \Webmozart\Console\Api\Command\NoSuchCommandException * @expectedExceptionMessage foobar */ public function testGetCommandFailsIfNotFound() { $application = new ConsoleApplication($this->config); $application->getCommand('foobar'); }