Merge remote-tracking branch 'adrianosferreira/package-install-method-cli'

Fixed formatting, and handling of config command to be preferred-install.foo value

Refs #8517
main
Jordi Boggiano 5 years ago
commit ee3fd0f745
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -466,6 +466,16 @@ EOT
},
),
);
$uniqueOrDotNestedArray = array(
'preferred-install' => array(
function ($val) {
return in_array($val, array('auto', 'source', 'dist'), true);
},
function ($val) {
return $val;
},
),
);
if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
@ -486,6 +496,23 @@ EOT
return 0;
}
// handle preferred-install per-package config
if (preg_match('/^preferred-install\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
$this->configSource->removeConfigSetting($settingKey);
return 0;
}
list($validator) = $uniqueConfigValues['preferred-install'];
if (!$validator($values[0])) {
throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
}
$this->configSource->addConfigSetting($settingKey, $values[0]);
return 0;
}
// handle properties
$uniqueProps = array(

@ -1814,6 +1814,51 @@ class JsonManipulatorTest extends TestCase
', $manipulator->getContents());
}
public function testAddConfigWithPackage() {
$manipulator = new JsonManipulator('{
"repositories": [
{
"type": "package",
"package": {
"authors": [],
"extra": {
"package-xml": "package.xml"
}
}
}
],
"config": {
"platform": {
"php": "5.3.9"
}
}
}');
$this->assertTrue($manipulator->addConfigSetting('preferred-install.my-organization/stable-package', 'dist'));
$this->assertEquals('{
"repositories": [
{
"type": "package",
"package": {
"authors": [],
"extra": {
"package-xml": "package.xml"
}
}
}
],
"config": {
"platform": {
"php": "5.3.9"
},
"preferred-install": {
"my-organization/stable-package": "dist"
}
}
}
', $manipulator->getContents());
}
public function testAddSuggestWithPackage()
{
$manipulator = new JsonManipulator('{

Loading…
Cancel
Save