1
0
Fork 0

Fix/add tests and also handle case where a json object is used

pull/9702/head
Jordi Boggiano 2021-02-11 11:13:58 +01:00
parent 4130d388fe
commit 52d7c6c383
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 27 additions and 8 deletions

View File

@ -179,12 +179,13 @@ class Config
continue;
}
// store repo
if (is_int($name)) {
// auto-deactivate the default packagist.org repo if it gets redefined
if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && preg_match('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
$this->disableRepoByName('packagist.org');
}
// store repo
if (is_int($name)) {
$this->repositories[] = $repository;
} else {
if ($name === 'packagist') { // BC support for default "packagist" named repo

View File

@ -35,7 +35,7 @@ class ConfigTest extends TestCase
$data = array();
$data['local config inherits system defaults'] = array(
array(
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
'packagist.org' => array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
array(),
);
@ -58,7 +58,7 @@ class ConfigTest extends TestCase
array(
1 => array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
0 => array('type' => 'pear', 'url' => 'http://pear.composer.org'),
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
'packagist.org' => array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
array(
array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
@ -69,7 +69,7 @@ class ConfigTest extends TestCase
$data['system config adds above core defaults'] = array(
array(
'example.com' => array('type' => 'composer', 'url' => 'http://example.com'),
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
'packagist.org' => array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
array(),
array(
@ -104,9 +104,27 @@ class ConfigTest extends TestCase
),
);
$data['local config redefining packagist.org by URL override it if no named keys are used'] = array(
array(
array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
array(
array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
);
$data['local config redefining packagist.org by URL override it also with named keys'] = array(
array(
'example' => array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
array(
'example' => array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
),
);
$data['incorrect local config does not cause ErrorException'] = array(
array(
'packagist.org' => array('type' => 'composer', 'url' => 'https?://repo.packagist.org', 'allow_ssl_downgrade' => true),
'packagist.org' => array('type' => 'composer', 'url' => 'https://repo.packagist.org'),
'type' => 'vcs',
'url' => 'http://example.com',
),