1
0
Fork 0

Disable packagist.org loading by default in initTempComposer test cases if other repos are provided

pull/10982/head
Jordi Boggiano 2022-08-16 10:41:58 +02:00
parent 7377d1f003
commit a6d872191c
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 7 additions and 3 deletions

View File

@ -123,17 +123,17 @@ class ConfigCommandTest extends TestCase
'vendor',
];
yield 'read repos by named key' => [
['repositories' => ['foo' => ['type' => 'vcs', 'url' => 'https://example.org']]],
['repositories' => ['foo' => ['type' => 'vcs', 'url' => 'https://example.org'], 'packagist.org' => ['type' => 'composer', 'url' => 'https://repo.packagist.org']]],
['setting-key' => 'repositories.foo'],
'{"type":"vcs","url":"https://example.org"}',
];
yield 'read repos by numeric index' => [
['repositories' => [['type' => 'vcs', 'url' => 'https://example.org']]],
['repositories' => [['type' => 'vcs', 'url' => 'https://example.org'], 'packagist.org' => ['type' => 'composer', 'url' => 'https://repo.packagist.org']]],
['setting-key' => 'repos.0'],
'{"type":"vcs","url":"https://example.org"}',
];
yield 'read all repos includes the default packagist' => [
['repositories' => ['foo' => ['type' => 'vcs', 'url' => 'https://example.org']]],
['repositories' => ['foo' => ['type' => 'vcs', 'url' => 'https://example.org'], 'packagist.org' => ['type' => 'composer', 'url' => 'https://repo.packagist.org']]],
['setting-key' => 'repos'],
'{"foo":{"type":"vcs","url":"https://example.org"},"packagist.org":{"type":"composer","url":"https://repo.packagist.org"}}',
];

View File

@ -137,6 +137,10 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
$authJson = new \stdClass;
}
if (is_array($composerJson) && isset($composerJson['repositories']) && !isset($composerJson['repositories']['packagist.org'])) {
$composerJson['repositories']['packagist.org'] = false;
}
chdir($dir);
file_put_contents($dir.'/composer.json', JsonFile::encode($composerJson, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
file_put_contents($dir.'/auth.json', JsonFile::encode($authJson, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));