X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fconsolidation%2Fconfig%2Ftests%2FConfigForCommandTest.php;fp=vendor%2Fconsolidation%2Fconfig%2Ftests%2FConfigForCommandTest.php;h=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=41da3076b347c91f819ae647b389518490915b9b;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/vendor/consolidation/config/tests/ConfigForCommandTest.php b/vendor/consolidation/config/tests/ConfigForCommandTest.php deleted file mode 100644 index 41da3076b..000000000 --- a/vendor/consolidation/config/tests/ConfigForCommandTest.php +++ /dev/null @@ -1,130 +0,0 @@ - [ - 'global' => 'from-config', - ], - // Define some configuration settings for the options for - // the commands my:foo and my:bar. - 'command' => [ - 'my' => [ - // commands.my.options.* apply to all my:* commands. - 'options' => [ - 'dir' => '/etc/common', - 'priority' => 'normal', - ], - 'foo' => [ - // commands.my.foo.options.* apply only to the my:foo command. - 'options' => [ - 'name' => 'baz', - ], - ], - ], - ], - ]; - - $this->config = new Config($data); - } - - public function testInjection() - { - $command = new MyFooCommand(); - $input = new StringInput('my:foo'); - - list($status, $output) = $this->runCommandViaApplication($command, $input); - - $expectedOutput = <<< EOT -Enter my:foo -dir: /etc/common -name: baz -other: fish -EOT; - - $this->assertEquals(0, $status); - $this->assertEquals($expectedOutput, $output); - } - - public function testInjectionWithOverride() - { - $command = new MyFooCommand(); - $input = new StringInput('my:foo --name=Fred'); - - list($status, $output) = $this->runCommandViaApplication($command, $input); - - $expectedOutput = <<< EOT -Enter my:foo -dir: /etc/common -name: Fred -other: fish -EOT; - - $this->assertEquals(0, $status); - $this->assertEquals($expectedOutput, $output); - } - - public function testHelpDefaultInjection() - { - $command = new MyFooCommand(); - $input = new StringInput('help my:foo'); - - list($status, $output) = $this->runCommandViaApplication($command, $input); - - $expectedOutput = <<< EOT -What is the name of the thing we are naming [default: "baz"] -EOT; - - $this->assertEquals(0, $status); - $this->assertContains($expectedOutput, $output); - - $expectedOutput = <<< EOT -A certain global option. [default: "from-config"] -EOT; - - $this->assertContains($expectedOutput, $output); - } - - protected function runCommandViaApplication($command, $input) - { - $application = new Application('TestApplication', '0.0.0'); - $application->getDefinition() - ->addOption( - new InputOption('--global', null, InputOption::VALUE_REQUIRED, 'A certain global option.', 'hardcoded') - ); - - $output = new BufferedOutput(); - - $configInjector = new ConfigForCommand($this->config); - $configInjector->setApplication($application); - - $eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher(); - $eventDispatcher->addSubscriber($configInjector); - $application->setDispatcher($eventDispatcher); - - $application->setAutoExit(false); - $application->add($command); - - $statusCode = $application->run($input, $output); - $commandOutput = trim($output->fetch()); - - return [$statusCode, $commandOutput]; - } -}