You are here

public function CommandTest::testMergeApplicationDefinition 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::testMergeApplicationDefinition()

File

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

Class

CommandTest

Namespace

Symfony\Component\Console\Tests\Command

Code

public function testMergeApplicationDefinition() {
  $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(
    new InputArgument('bar'),
    new InputOption('foo'),
  )));
  $r = new \ReflectionObject($command);
  $m = $r
    ->getMethod('mergeApplicationDefinition');
  $m
    ->setAccessible(true);
  $m
    ->invoke($command);
  $this
    ->assertTrue($command
    ->getDefinition()
    ->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments');
  $this
    ->assertTrue($command
    ->getDefinition()
    ->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments');
  $this
    ->assertTrue($command
    ->getDefinition()
    ->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options');
  $this
    ->assertTrue($command
    ->getDefinition()
    ->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options');
  $m
    ->invoke($command);
  $this
    ->assertEquals(3, $command
    ->getDefinition()
    ->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options');
}