public function testCreateWithConfigClosure() { $config = $this->config; $config->addArgument('argument'); $config->addOption('option', 'o'); // This feature is useful when the Config constructor might throw an // exception which should be rendered nicely $application = new ConsoleApplication(function () use($config) { return $config; }); $this->assertSame($this->config, $application->getConfig()); $this->assertEquals(new ArgsFormat(array(new Argument('argument'), new Option('option', 'o'))), $application->getGlobalArgsFormat()); }
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')); }