X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fconsolidation%2Fconfig%2Ftests%2FConfigGroupTest.php;fp=vendor%2Fconsolidation%2Fconfig%2Ftests%2FConfigGroupTest.php;h=21e470e575f7c784f7142051611dc4a2942881dd;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/consolidation/config/tests/ConfigGroupTest.php b/vendor/consolidation/config/tests/ConfigGroupTest.php new file mode 100644 index 000000000..21e470e57 --- /dev/null +++ b/vendor/consolidation/config/tests/ConfigGroupTest.php @@ -0,0 +1,91 @@ + [ + 'my' => [ + // commands.my.options.* apply to all my:* commands. + 'options' => [ + 'path' => '/etc/common', + 'priority' => 'normal', + ], + 'foo' => [ + // commands.my.foo.options.* apply only to the my:foo command. + 'options' => [ + 'name' => 'baz', + ], + ], + 'bar' => [ + // Similarly, commands.my.bar.options is for the my:bar command. + 'options' => [ + 'priority' => 'high', + ], + ], + ], + ], + // Define some configuration settings for the configuration + // of some task \My\Tasks\Operations\Frobulate. + 'task' => [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'object' => 'fire truck', + ], + ], + ], + ], + ]; + + $this->config = new Config($data); + } + + public function testDotNotation() + { + // Test the test + $this->assertEquals('baz', $this->config->get('command.my.foo.options.name')); + } + + public function testFallback() + { + $fooFallback = new ConfigFallback($this->config, 'my.foo', 'command.', '.options.'); + $barFallback = new ConfigFallback($this->config, 'my.bar', 'command.', '.options.'); + + $this->assertEquals(null, $barFallback->get('name')); + $this->assertEquals('baz', $fooFallback->get('name')); + $this->assertEquals('high', $barFallback->get('priority')); + + $this->assertEquals('normal', $fooFallback->get('priority')); + $this->assertEquals('/etc/common', $barFallback->get('path')); + $this->assertEquals('/etc/common', $fooFallback->get('path')); + } + + public function testMerge() + { + $frobulateMerge = new ConfigMerge($this->config, 'Operations.Frobulate', 'task.'); + + $settings = $frobulateMerge->get('settings'); + $this->assertEquals('fire truck', $settings['object']); + $this->assertEquals('/base/dir', $settings['dir']); + $keys = array_keys($settings); + sort($keys); + $this->assertEquals('dir,object', implode(',', $keys)); + } +} +