You are here

public function CommandTest::testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Tests/Command/CommandTest.php \Symfony\Component\Console\Tests\Command\CommandTest::testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs()

File

vendor/symfony/console/Tests/Command/CommandTest.php, line 194

Class

CommandTest

Namespace

Symfony\Component\Console\Tests\Command

Code

public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs() {
  $application1 = new Application();
  $application1
    ->getDefinition()
    ->addArguments(array(
    new InputArgument('foo'),
  ));
  $application1
    ->getDefinition()
    ->addOptions(array(
    new InputOption('bar'),
  ));
  $command = new \TestCommand();
  $command
    ->setApplication($application1);
  $command
    ->setDefinition($definition = new InputDefinition(array()));
  $r = new \ReflectionObject($command);
  $m = $r
    ->getMethod('mergeApplicationDefinition');
  $m
    ->setAccessible(true);
  $m
    ->invoke($command, false);
  $this
    ->assertTrue($command
    ->getDefinition()
    ->hasOption('bar'), '->mergeApplicationDefinition(false) merges the application and the command options');
  $this
    ->assertFalse($command
    ->getDefinition()
    ->hasArgument('foo'), '->mergeApplicationDefinition(false) does not merge the application arguments');
  $m
    ->invoke($command, true);
  $this
    ->assertTrue($command
    ->getDefinition()
    ->hasArgument('foo'), '->mergeApplicationDefinition(true) merges the application arguments and the command arguments');
  $m
    ->invoke($command);
  $this
    ->assertEquals(2, $command
    ->getDefinition()
    ->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments');
}