Merge remote-tracking branch 'adrianosferreira/package-install-method-cli'
Fixed formatting, and handling of config command to be preferred-install.foo value Refs #8517pull/8538/head
commit
ee3fd0f745
|
@ -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 ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
|
||||||
if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
|
if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
|
||||||
|
@ -486,6 +496,23 @@ EOT
|
||||||
|
|
||||||
return 0;
|
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
|
// handle properties
|
||||||
$uniqueProps = array(
|
$uniqueProps = array(
|
||||||
|
|
|
@ -1814,6 +1814,51 @@ class JsonManipulatorTest extends TestCase
|
||||||
', $manipulator->getContents());
|
', $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()
|
public function testAddSuggestWithPackage()
|
||||||
{
|
{
|
||||||
$manipulator = new JsonManipulator('{
|
$manipulator = new JsonManipulator('{
|
||||||
|
|
Loading…
Reference in New Issue