create() public static méthode

Creates a new console application.
public static create ( string $name = null, string $version = null ) : static
$name string The name of the application.
$version string The application version.
Résultat static The created instance.
 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());
    }
 public function testStaticCreateWithArguments()
 {
     $config = ApplicationConfig::create('name', 'version');
     $this->assertSame('name', $config->getName());
     $this->assertSame('version', $config->getVersion());
 }
    public function testRenderDescription()
    {
        $config = ApplicationConfig::create()->setHelp('The help');
        $application = new ConsoleApplication($config);
        $help = new ApplicationHelp($application);
        $help->render($this->io);
        $expected = <<<'EOF'
Console Tool

USAGE
  console <command> [<arg1>] ... [<argN>]

ARGUMENTS
  <command>  The command to execute
  <arg>      The arguments of the command

DESCRIPTION
  The help


EOF;
        $this->assertSame($expected, $this->io->fetchOutput());
    }