Add pear modules, mail and net_smtp via composer (#93)
Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
130
lib/composer/vendor/consolidation/config/tests/ConfigForCommandTest.php
vendored
Normal file
130
lib/composer/vendor/consolidation/config/tests/ConfigForCommandTest.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
namespace Consolidation\Config\Inject;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
use Consolidation\TestUtils\MyFooCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ConfigForCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $config;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$data = [
|
||||
// Global options
|
||||
'options' => [
|
||||
'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];
|
||||
}
|
||||
}
|
||||
87
lib/composer/vendor/consolidation/config/tests/ConfigForSettersTest.php
vendored
Normal file
87
lib/composer/vendor/consolidation/config/tests/ConfigForSettersTest.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
namespace Consolidation\Config\Inject;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
use Consolidation\TestUtils\ApplyConfigTestTarget;
|
||||
|
||||
class ConfigForSettersTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testApplyConfig()
|
||||
{
|
||||
$data = [
|
||||
// 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' => [
|
||||
'dir' => '/override/dir',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$config = new Config($data);
|
||||
|
||||
$applicator = new ConfigForSetters($config, 'Operations.Frobulate', 'task.');
|
||||
|
||||
$testTarget = new ApplyConfigTestTarget();
|
||||
|
||||
$applicator->apply($testTarget, 'settings');
|
||||
|
||||
$this->assertEquals('/override/dir', $testTarget->getDir());
|
||||
$this->assertEquals(null, $testTarget->getBad());
|
||||
}
|
||||
|
||||
public function testApplyBadConfig()
|
||||
{
|
||||
$data = [
|
||||
// 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' => [
|
||||
'bad' => 'fire truck',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$config = new Config($data);
|
||||
|
||||
$applicator = new ConfigForSetters($config, 'Operations.Frobulate', 'task.');
|
||||
|
||||
$testTarget = new ApplyConfigTestTarget();
|
||||
|
||||
$exceptionMessage = '';
|
||||
try
|
||||
{
|
||||
$applicator->apply($testTarget, 'settings');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$exceptionMessage = $e->getMessage();
|
||||
}
|
||||
// We would prefer it if bad methods were never called; unfortunately,
|
||||
// declaring the return type of a method cannot be done in a reliable
|
||||
// way (via reflection) until php 7, so we allow these methods to be
|
||||
// called for now.
|
||||
$this->assertEquals('fire truck', $testTarget->getBad());
|
||||
$this->assertEquals('Consolidation\\TestUtils\\ApplyConfigTestTarget::bad did not return \'$this\' when processing task.Operations.Frobulate.settings.', $exceptionMessage);
|
||||
}
|
||||
}
|
||||
91
lib/composer/vendor/consolidation/config/tests/ConfigGroupTest.php
vendored
Normal file
91
lib/composer/vendor/consolidation/config/tests/ConfigGroupTest.php
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
namespace Consolidation\Config\Util;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
|
||||
class ConfigGroupTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $config;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$data = [
|
||||
// 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' => [
|
||||
'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));
|
||||
}
|
||||
}
|
||||
|
||||
29
lib/composer/vendor/consolidation/config/tests/ConfigLoaderTest.php
vendored
Normal file
29
lib/composer/vendor/consolidation/config/tests/ConfigLoaderTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Consolidation\Config\Loader;
|
||||
|
||||
class ConfigLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConfigLoader()
|
||||
{
|
||||
$loader = new YamlConfigLoader();
|
||||
|
||||
// Assert that our test data exists (test the test)
|
||||
$path = __DIR__ . '/data/config-1.yml';
|
||||
$this->assertTrue(file_exists($path));
|
||||
|
||||
$loader->load($path);
|
||||
|
||||
$configFile = basename($loader->getSourceName());
|
||||
$this->assertEquals('config-1.yml', $configFile);
|
||||
|
||||
// Make sure that the data we loaded contained the expected keys
|
||||
$keys = $loader->keys();
|
||||
sort($keys);
|
||||
$keysString = implode(',', $keys);
|
||||
$this->assertEquals('c,m', $keysString);
|
||||
|
||||
$configData = $loader->export();
|
||||
$this->assertEquals('foo', $configData['c']);
|
||||
$this->assertEquals('1', $configData['m'][0]);
|
||||
}
|
||||
}
|
||||
168
lib/composer/vendor/consolidation/config/tests/ConfigOverlayTest.php
vendored
Normal file
168
lib/composer/vendor/consolidation/config/tests/ConfigOverlayTest.php
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
namespace Consolidation\Config\Util;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
use Consolidation\Config\Loader\ConfigProcessor;
|
||||
use Consolidation\Config\Loader\YamlConfigLoader;
|
||||
|
||||
class ConfigOverlayTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $overlay;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$aliasContext = new Config();
|
||||
$aliasContext->import([
|
||||
'hidden-by-a' => 'alias hidden-by-a',
|
||||
'hidden-by-process' => 'alias hidden-by-process',
|
||||
'options' =>[
|
||||
'a-a' => 'alias-a',
|
||||
],
|
||||
'command' => [
|
||||
'foo' => [
|
||||
'bar' => [
|
||||
'command' => [
|
||||
'options' => [
|
||||
'a-b' => 'alias-b',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$configFileContext = new Config();
|
||||
$configFileContext->import([
|
||||
'hidden-by-cf' => 'config-file hidden-by-cf',
|
||||
'hidden-by-a' => 'config-file hidden-by-a',
|
||||
'hidden-by-process' => 'config-file hidden-by-process',
|
||||
'options' =>[
|
||||
'cf-a' => 'config-file-a',
|
||||
],
|
||||
'command' => [
|
||||
'foo' => [
|
||||
'bar' => [
|
||||
'command' => [
|
||||
'options' => [
|
||||
'cf-b' => 'config-file-b',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->overlay = new ConfigOverlay();
|
||||
$this->overlay->set('hidden-by-process', 'process-h');
|
||||
$this->overlay->addContext('cf', $configFileContext);
|
||||
$this->overlay->addContext('a', $aliasContext);
|
||||
$this->overlay->setDefault('df-a', 'default');
|
||||
$this->overlay->setDefault('hidden-by-a', 'default hidden-by-a');
|
||||
$this->overlay->setDefault('hidden-by-cf', 'default hidden-by-cf');
|
||||
$this->overlay->setDefault('hidden-by-process', 'default hidden-by-process');
|
||||
}
|
||||
|
||||
public function testGetPriority()
|
||||
{
|
||||
$this->assertEquals('process-h', $this->overlay->get('hidden-by-process'));
|
||||
$this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf'));
|
||||
$this->assertEquals('alias hidden-by-a', $this->overlay->get('hidden-by-a'));
|
||||
}
|
||||
|
||||
public function testDefault()
|
||||
{
|
||||
$this->assertEquals('alias-a', $this->overlay->get('options.a-a'));
|
||||
$this->assertEquals('alias-a', $this->overlay->get('options.a-a', 'ignored'));
|
||||
$this->assertEquals('default', $this->overlay->getDefault('df-a', 'ignored'));
|
||||
$this->assertEquals('nsv', $this->overlay->getDefault('a-a', 'nsv'));
|
||||
|
||||
$this->overlay->setDefault('df-a', 'new value');
|
||||
$this->assertEquals('new value', $this->overlay->getDefault('df-a', 'ignored'));
|
||||
}
|
||||
|
||||
public function testExport()
|
||||
{
|
||||
$data = $this->overlay->export();
|
||||
|
||||
$this->assertEquals('config-file-a', $data['options']['cf-a']);
|
||||
$this->assertEquals('alias-a', $data['options']['a-a']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testImport()
|
||||
{
|
||||
$data = $this->overlay->import(['a' => 'value']);
|
||||
}
|
||||
|
||||
public function testMaintainPriority()
|
||||
{
|
||||
// Get and re-add the 'cf' context. Its priority should not change.
|
||||
$configFileContext = $this->overlay->getContext('cf');
|
||||
$this->overlay->addContext('cf', $configFileContext);
|
||||
|
||||
// These asserts are the same as in testGetPriority
|
||||
$this->assertEquals('process-h', $this->overlay->get('hidden-by-process'));
|
||||
$this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf'));
|
||||
$this->assertEquals('alias hidden-by-a', $this->overlay->get('hidden-by-a'));
|
||||
}
|
||||
|
||||
public function testChangePriority()
|
||||
{
|
||||
// Increase the priority of the 'cf' context. Now, it should have a higher
|
||||
// priority than the 'alias' context, but should still have a lower
|
||||
// priority than the 'process' context.
|
||||
$this->overlay->increasePriority('cf');
|
||||
|
||||
// These asserts are the same as in testGetPriority
|
||||
$this->assertEquals('process-h', $this->overlay->get('hidden-by-process'));
|
||||
$this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf'));
|
||||
|
||||
// This one has changed: the config-file value is now found instead
|
||||
// of the alias value.
|
||||
$this->assertEquals('config-file hidden-by-a', $this->overlay->get('hidden-by-a'));
|
||||
}
|
||||
|
||||
public function testPlaceholder()
|
||||
{
|
||||
$this->overlay->addPlaceholder('lower');
|
||||
|
||||
$higherContext = new Config();
|
||||
$higherContext->import(['priority-test' => 'higher']);
|
||||
|
||||
$lowerContext = new Config();
|
||||
$lowerContext->import(['priority-test' => 'lower']);
|
||||
|
||||
// Usually 'lower' would have the highest priority, since it is
|
||||
// added last. However, our earlier call to 'addPlaceholder' reserves
|
||||
// a spot for it, so the 'higher' context will end up with a higher
|
||||
// priority.
|
||||
$this->overlay->addContext('higher', $higherContext);
|
||||
$this->overlay->addContext('lower', $lowerContext);
|
||||
$this->assertEquals('higher', $this->overlay->get('priority-test', 'neither'));
|
||||
|
||||
// Test to see that we can change the value of the 'higher' context,
|
||||
// and the change will be reflected in the overlay.
|
||||
$higherContext->set('priority-test', 'changed');
|
||||
$this->assertEquals('changed', $this->overlay->get('priority-test', 'neither'));
|
||||
|
||||
// Test to see that the 'process' context still has the highest priority.
|
||||
$this->overlay->set('priority-test', 'process');
|
||||
$higherContext->set('priority-test', 'ignored');
|
||||
$this->assertEquals('process', $this->overlay->get('priority-test', 'neither'));
|
||||
}
|
||||
|
||||
public function testDoesNotHave()
|
||||
{
|
||||
$context = $this->overlay->getContext('no-such-context');
|
||||
$data = $context->export();
|
||||
$this->assertEquals('[]', json_encode($data));
|
||||
|
||||
$this->assertTrue(!$this->overlay->has('no-such-key'));
|
||||
$this->assertTrue(!$this->overlay->hasDefault('no-such-default'));
|
||||
|
||||
$this->assertEquals('no-such-value', $this->overlay->get('no-such-key', 'no-such-value'));
|
||||
|
||||
}
|
||||
}
|
||||
152
lib/composer/vendor/consolidation/config/tests/ConfigProcessorTest.php
vendored
Normal file
152
lib/composer/vendor/consolidation/config/tests/ConfigProcessorTest.php
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace Consolidation\Config\Loader;
|
||||
|
||||
use Consolidation\TestUtils\TestLoader;
|
||||
|
||||
class ConfigProcessorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConfigProcessorAdd()
|
||||
{
|
||||
$config1 = [
|
||||
'c' => 'foo',
|
||||
'm' => [1],
|
||||
];
|
||||
$config2 = [
|
||||
'b' => '${c}bar',
|
||||
'm' => [2],
|
||||
];
|
||||
$config3 = [
|
||||
'a' => '${b}baz',
|
||||
'm' => [3],
|
||||
];
|
||||
|
||||
$processor = new ConfigProcessor();
|
||||
$processor->add($config1);
|
||||
$processor->add($config2);
|
||||
$processor->add($config3);
|
||||
|
||||
$data = $processor->export();
|
||||
$this->assertEquals('foo', $data['c']);
|
||||
$this->assertEquals('foobar', $data['b']);
|
||||
$this->assertEquals('foobarbaz', $data['a']);
|
||||
}
|
||||
|
||||
public function processorForConfigMergeTest($provideSourceNames)
|
||||
{
|
||||
$config1 = [
|
||||
'm' => [
|
||||
'x' => 'x-1',
|
||||
'y' => [
|
||||
'r' => 'r-1',
|
||||
's' => 's-1',
|
||||
't' => 't-1',
|
||||
],
|
||||
'z' => 'z-1',
|
||||
],
|
||||
];
|
||||
$config2 = [
|
||||
'm' => [
|
||||
'w' => 'w-2',
|
||||
'y' => [
|
||||
'q' => 'q-2',
|
||||
's' => 's-2',
|
||||
],
|
||||
'z' => 'z-2',
|
||||
],
|
||||
];
|
||||
$config3 = [
|
||||
'm' => [
|
||||
'v' => 'v-3',
|
||||
'y' => [
|
||||
't' => 't-3',
|
||||
'u' => 'u-3',
|
||||
],
|
||||
'z' => 'z-3',
|
||||
],
|
||||
];
|
||||
|
||||
$processor = new ConfigProcessor();
|
||||
$testLoader = new TestLoader();
|
||||
|
||||
$testLoader->set($config1);
|
||||
$testLoader->setSourceName($provideSourceNames ? 'c-1' : '');
|
||||
$processor->extend($testLoader);
|
||||
|
||||
$testLoader->set($config2);
|
||||
$testLoader->setSourceName($provideSourceNames ? 'c-2' : '');
|
||||
$processor->extend($testLoader);
|
||||
|
||||
$testLoader->set($config3);
|
||||
$testLoader->setSourceName($provideSourceNames ? 'c-3' : '');
|
||||
$processor->extend($testLoader);
|
||||
|
||||
return $processor;
|
||||
}
|
||||
|
||||
public function testConfigProcessorMergeAssociative()
|
||||
{
|
||||
$processor = $this->processorForConfigMergeTest(false);
|
||||
$data = $processor->export();
|
||||
$this->assertEquals('{"m":{"x":"x-1","y":{"r":"r-1","s":"s-2","t":"t-3","q":"q-2","u":"u-3"},"z":"z-3","w":"w-2","v":"v-3"}}', json_encode($data));
|
||||
}
|
||||
|
||||
public function testConfigProcessorMergeAssociativeWithSourceNames()
|
||||
{
|
||||
$processor = $this->processorForConfigMergeTest(true);
|
||||
$sources = $processor->sources();
|
||||
$data = $processor->export();
|
||||
$this->assertEquals('{"m":{"x":"x-1","y":{"r":"r-1","s":"s-2","t":"t-3","q":"q-2","u":"u-3"},"z":"z-3","w":"w-2","v":"v-3"}}', json_encode($data));
|
||||
$this->assertEquals('c-1', $sources['m']['x']);
|
||||
$this->assertEquals('c-1', $sources['m']['y']['r']);
|
||||
$this->assertEquals('c-2', $sources['m']['w']);
|
||||
$this->assertEquals('c-2', $sources['m']['y']['s']);
|
||||
$this->assertEquals('c-3', $sources['m']['z']);
|
||||
$this->assertEquals('c-3', $sources['m']['y']['u']);
|
||||
}
|
||||
|
||||
public function testConfiProcessorSources()
|
||||
{
|
||||
$processor = new ConfigProcessor();
|
||||
$loader = new YamlConfigLoader();
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-1.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-2.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-3.yml'));
|
||||
|
||||
$sources = $processor->sources();
|
||||
|
||||
$data = $processor->export();
|
||||
$this->assertEquals('foo', $data['c']);
|
||||
$this->assertEquals('foobar', $data['b']);
|
||||
$this->assertEquals('foobarbaz', $data['a']);
|
||||
|
||||
$this->assertEquals('3', $data['m'][0]);
|
||||
|
||||
$this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['a']);
|
||||
$this->assertEquals( __DIR__ . '/data/config-2.yml', $sources['b']);
|
||||
$this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['c']);
|
||||
$this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['m']);
|
||||
}
|
||||
|
||||
public function testConfiProcessorSourcesLoadInReverseOrder()
|
||||
{
|
||||
$processor = new ConfigProcessor();
|
||||
$loader = new YamlConfigLoader();
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-3.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-2.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-1.yml'));
|
||||
|
||||
$sources = $processor->sources();
|
||||
|
||||
$data = $processor->export();
|
||||
$this->assertEquals('foo', $data['c']);
|
||||
$this->assertEquals('foobar', $data['b']);
|
||||
$this->assertEquals('foobarbaz', $data['a']);
|
||||
|
||||
$this->assertEquals('1', $data['m'][0]);
|
||||
|
||||
$this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['a']);
|
||||
$this->assertEquals( __DIR__ . '/data/config-2.yml', $sources['b']);
|
||||
$this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['c']);
|
||||
$this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['m']);
|
||||
}
|
||||
}
|
||||
140
lib/composer/vendor/consolidation/config/tests/ConfigTest.php
vendored
Normal file
140
lib/composer/vendor/consolidation/config/tests/ConfigTest.php
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
namespace Consolidation\Config;
|
||||
|
||||
use Consolidation\Config\Loader\ConfigProcessor;
|
||||
use Consolidation\Config\Loader\YamlConfigLoader;
|
||||
|
||||
class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSetters()
|
||||
{
|
||||
// Pointless tests just to ensure everything is covered.
|
||||
$config = new Config();
|
||||
$config->set('foo', 'bar');
|
||||
$data = $config->export();
|
||||
$this->assertEquals('{"foo":"bar"}', json_encode($data));
|
||||
}
|
||||
|
||||
public function testCombine()
|
||||
{
|
||||
// Pointless tests just to ensure everything is covered.
|
||||
$config = new Config();
|
||||
$config->set('foo', 'bar');
|
||||
$config->set('baz', 'boz');
|
||||
$config2 = new Config();
|
||||
$config2->set('foo', 'fu');
|
||||
$config2->set('new', 'blue');
|
||||
$config->combine($config2->export());
|
||||
$this->assertEquals('fu', $config->get('foo'));
|
||||
$this->assertEquals('boz', $config->get('baz'));
|
||||
$this->assertEquals('blue', $config->get('new'));
|
||||
}
|
||||
|
||||
public function testDefault()
|
||||
{
|
||||
$data = [
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'boz',
|
||||
];
|
||||
|
||||
$foo = ["foo" => "bar"];
|
||||
|
||||
$config = new Config($data);
|
||||
|
||||
$config->setDefault('c', 'other');
|
||||
$config->setDefault('d', 'other');
|
||||
$config->setDefault('f', $foo);
|
||||
|
||||
$this->assertEquals('foo', $config->get('a'));
|
||||
$this->assertEquals('boz', $config->get('c'));
|
||||
$this->assertEquals('other', $config->get('d'));
|
||||
$this->assertEquals('other', $config->getDefault('c'));
|
||||
$this->assertEquals('', $config->get('e'));
|
||||
$this->assertEquals('bar', $config->get('f.foo'));
|
||||
$this->assertEquals('{"foo":"bar"}', json_encode($config->get('f')));
|
||||
}
|
||||
|
||||
public function testDefaultsArray()
|
||||
{
|
||||
$data = ['a' => 'foo', 'b' => 'bar', 'c' => 'boz',];
|
||||
$defaults = ['d' => 'foo', 'e' => 'bar', 'f' => 'boz',];
|
||||
|
||||
// Create reflection class to test private methods
|
||||
$configClass = new \ReflectionClass("Consolidation\Config\Config");
|
||||
|
||||
// $defaults
|
||||
$defaultsProperty = $configClass->getProperty("defaults");
|
||||
$defaultsProperty->setAccessible(true);
|
||||
|
||||
// $getDefaults
|
||||
$getDefaultsMethod = $configClass->getMethod("getDefaults");
|
||||
$getDefaultsMethod->setAccessible(true);
|
||||
|
||||
// Test the config class
|
||||
$config = new Config($data);
|
||||
|
||||
// Set $config::defaults to an array to test getter and setter
|
||||
$defaultsProperty->setValue($config, $defaults);
|
||||
$this->assertTrue(is_array($defaultsProperty->getValue($config)));
|
||||
$this->assertInstanceOf('Dflydev\DotAccessData\Data',
|
||||
$getDefaultsMethod->invoke($config));
|
||||
|
||||
// Set $config::defaults to a string to test exception
|
||||
$defaultsProperty->setValue($config, "foo.bar");
|
||||
$this->setExpectedException("Exception");
|
||||
$getDefaultsMethod->invoke($config);
|
||||
}
|
||||
|
||||
public function testConfigurationWithCrossFileReferences()
|
||||
{
|
||||
$config = new Config();
|
||||
$processor = new ConfigProcessor();
|
||||
$loader = new YamlConfigLoader();
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-1.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-2.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-3.yml'));
|
||||
|
||||
// Does not fail if configuration file cannot be found
|
||||
$processor->extend($loader->load(__DIR__ . '/data/no-such-file.yml'));
|
||||
|
||||
// We must capture the sources before exporting, as export
|
||||
// dumps this information.
|
||||
$sources = $processor->sources();
|
||||
|
||||
$config->import($processor->export());
|
||||
|
||||
$this->assertEquals(implode(',', $config->get('m')), '3');
|
||||
$this->assertEquals($config->get('a'), 'foobarbaz');
|
||||
|
||||
$this->assertEquals($sources['a'], __DIR__ . '/data/config-3.yml');
|
||||
$this->assertEquals($sources['b'], __DIR__ . '/data/config-2.yml');
|
||||
$this->assertEquals($sources['c'], __DIR__ . '/data/config-1.yml');
|
||||
}
|
||||
|
||||
public function testConfigurationWithReverseOrderCrossFileReferences()
|
||||
{
|
||||
$config = new Config();
|
||||
$processor = new ConfigProcessor();
|
||||
$loader = new YamlConfigLoader();
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-3.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-2.yml'));
|
||||
$processor->extend($loader->load(__DIR__ . '/data/config-1.yml'));
|
||||
|
||||
$sources = $processor->sources();
|
||||
$config->import($processor->export());
|
||||
|
||||
$this->assertEquals(implode(',', $config->get('m')), '1');
|
||||
|
||||
if (strpos($config->get('a'), '$') !== false) {
|
||||
throw new \PHPUnit_Framework_SkippedTestError(
|
||||
'Evaluation of cross-file references in reverse order not supported.'
|
||||
);
|
||||
}
|
||||
$this->assertEquals($config->get('a'), 'foobarbaz');
|
||||
|
||||
$this->assertEquals($sources['a'], __DIR__ . '/data/config-3.yml');
|
||||
$this->assertEquals($sources['b'], __DIR__ . '/data/config-2.yml');
|
||||
$this->assertEquals($sources['c'], __DIR__ . '/data/config-1.yml');
|
||||
}
|
||||
}
|
||||
3
lib/composer/vendor/consolidation/config/tests/data/config-1.yml
vendored
Normal file
3
lib/composer/vendor/consolidation/config/tests/data/config-1.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
c: foo
|
||||
m:
|
||||
- 1
|
||||
3
lib/composer/vendor/consolidation/config/tests/data/config-2.yml
vendored
Normal file
3
lib/composer/vendor/consolidation/config/tests/data/config-2.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
b: ${c}bar
|
||||
m:
|
||||
- 2
|
||||
3
lib/composer/vendor/consolidation/config/tests/data/config-3.yml
vendored
Normal file
3
lib/composer/vendor/consolidation/config/tests/data/config-3.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
a: ${b}baz
|
||||
m:
|
||||
- 3
|
||||
23
lib/composer/vendor/consolidation/config/tests/scripts/install-scenario
vendored
Executable file
23
lib/composer/vendor/consolidation/config/tests/scripts/install-scenario
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCENARIO=$1
|
||||
ACTION=${2-install}
|
||||
|
||||
dir=dependencies/${SCENARIO}
|
||||
if [ -z "$SCENARIO" ] ; then
|
||||
SCENARIO=default
|
||||
dir=.
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d "$dir" ] ; then
|
||||
echo "Requested scenario '${SCENARIO}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Switch to ${SCENARIO} scenario"
|
||||
|
||||
set -ex
|
||||
|
||||
composer -n --working-dir=$dir ${ACTION} --prefer-dist --no-scripts
|
||||
composer -n --working-dir=$dir info
|
||||
66
lib/composer/vendor/consolidation/config/tests/scripts/prep-dependencies
vendored
Executable file
66
lib/composer/vendor/consolidation/config/tests/scripts/prep-dependencies
vendored
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# This script is called automatically on every `composer update`.
|
||||
# See "post-update-cmd" in the "scripts" section of composer.json.
|
||||
#
|
||||
# This script will create a derived composer.json / composer.lock
|
||||
# pair for every test scenario. Test scenarios are defined in the
|
||||
# "scenarios" file, which should be customized to suit the needs
|
||||
# of the project.
|
||||
#
|
||||
|
||||
SELF_DIRNAME="`dirname -- "$0"`"
|
||||
source ${SELF_DIRNAME}/scenarios
|
||||
|
||||
echo
|
||||
echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
|
||||
echo "::"
|
||||
echo ":: Update dependencies for the following scenarios:"
|
||||
echo "::"
|
||||
echo ":: ${SCENARIOS}"
|
||||
echo "::"
|
||||
echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
|
||||
echo
|
||||
|
||||
set -ex
|
||||
|
||||
for SCENARIO in ${SCENARIOS} ; do
|
||||
|
||||
dir=dependencies/${SCENARIO}
|
||||
|
||||
# Define indirect variable names
|
||||
stability_variable="stability_${SCENARIO}"
|
||||
requirement_variable="requirement_${SCENARIO}"
|
||||
platform_php_variable="platform_php_${SCENARIO}"
|
||||
|
||||
echo "### Create $dir/composer.json for ${SCENARIO} scenario"
|
||||
mkdir -p $dir
|
||||
cp composer.json $dir
|
||||
|
||||
# Then set our own platform php version if applicable (otherwise unset it)
|
||||
composer -n --working-dir=$dir config platform.php "${!platform_php_variable---unset}"
|
||||
|
||||
# Temporarily set our vendor directory to 'vendor'
|
||||
composer -n --working-dir=$dir config vendor-dir vendor
|
||||
|
||||
# Set an appropriate minimum stability for this version of Symfony
|
||||
composer -n --working-dir=$dir config minimum-stability "${!stability_variable-stable}"
|
||||
|
||||
# Add a constraint to limit the Symfony version
|
||||
composer -n --working-dir=$dir require --dev --no-update "${!requirement_variable}"
|
||||
|
||||
# Create the composer.lock file. Ignore the vendor directory created.
|
||||
composer -n --working-dir=$dir update --no-scripts
|
||||
|
||||
# Set the vendor directory to its final desired location.
|
||||
composer -n --working-dir=$dir config vendor-dir '../../vendor'
|
||||
|
||||
# The 'autoload' section specifies directory paths that are relative
|
||||
# to the composer.json file. We will drop in some symlinks so that
|
||||
# these paths will resolve as if the composer.json were in the root.
|
||||
for target in $AUTOLOAD_DIRECTORIES ; do
|
||||
ln -s -f ../../$target $dir
|
||||
done
|
||||
|
||||
done
|
||||
12
lib/composer/vendor/consolidation/config/tests/scripts/scenarios
vendored
Executable file
12
lib/composer/vendor/consolidation/config/tests/scripts/scenarios
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCENARIOS="symfony2 symfony3 symfony4"
|
||||
|
||||
AUTOLOAD_DIRECTORIES='src tests'
|
||||
|
||||
platform_php_symfony2='5.4'
|
||||
platform_php_symfony3='5.6'
|
||||
|
||||
requirement_symfony2='symfony/console:^2.8'
|
||||
requirement_symfony3='symfony/console:^3'
|
||||
requirement_symfony4='symfony/console:^4'
|
||||
43
lib/composer/vendor/consolidation/config/tests/src/ApplyConfigTestTarget.php
vendored
Normal file
43
lib/composer/vendor/consolidation/config/tests/src/ApplyConfigTestTarget.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Consolidation\TestUtils;
|
||||
|
||||
class ApplyConfigTestTarget
|
||||
{
|
||||
protected $dir;
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* A proper setter for the 'dir' property
|
||||
*/
|
||||
public function dir($dir)
|
||||
{
|
||||
$this->dir = $dir;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A getter for the 'dir' property that we will use to
|
||||
* determine if the setter was called.
|
||||
*/
|
||||
public function getDir()
|
||||
{
|
||||
return $this->dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* A bad setter that does not return $this.
|
||||
*/
|
||||
public function bad($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A getter for the bad setter.
|
||||
*/
|
||||
public function getBad()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
47
lib/composer/vendor/consolidation/config/tests/src/MyFooCommand.php
vendored
Normal file
47
lib/composer/vendor/consolidation/config/tests/src/MyFooCommand.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace Consolidation\TestUtils;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MyFooCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('my:foo')
|
||||
->setDescription('My foo command.')
|
||||
->setHelp('This command tests command option injection by echoing its options')
|
||||
->addOption(
|
||||
'other',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'Some other option',
|
||||
'fish'
|
||||
)
|
||||
->addOption(
|
||||
'name',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'What is the name of the thing we are naming',
|
||||
'George'
|
||||
)
|
||||
->addOption(
|
||||
'dir',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'What is the base directory to use for this command',
|
||||
'/default/path'
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('Enter my:foo');
|
||||
$output->writeln('dir: ' . $input->getOption('dir'));
|
||||
$output->writeln('name: ' . $input->getOption('name'));
|
||||
$output->writeln('other: ' . $input->getOption('other'));
|
||||
}
|
||||
}
|
||||
36
lib/composer/vendor/consolidation/config/tests/src/TestLoader.php
vendored
Normal file
36
lib/composer/vendor/consolidation/config/tests/src/TestLoader.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Consolidation\TestUtils;
|
||||
|
||||
use Consolidation\Config\Loader\ConfigLoaderInterface;
|
||||
|
||||
class TestLoader implements ConfigLoaderInterface
|
||||
{
|
||||
protected $data;
|
||||
protected $sourceName;
|
||||
|
||||
public function set($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function setSourceName($name)
|
||||
{
|
||||
$this->sourceName = $name;
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function keys()
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
|
||||
public function getSourceName()
|
||||
{
|
||||
return $this->sourceName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user