From a6d872191c14a00d907801c284756100d44c3f86 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 16 Aug 2022 10:41:58 +0200 Subject: [PATCH] Disable packagist.org loading by default in initTempComposer test cases if other repos are provided --- tests/Composer/Test/Command/ConfigCommandTest.php | 6 +++--- tests/Composer/Test/TestCase.php | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Composer/Test/Command/ConfigCommandTest.php b/tests/Composer/Test/Command/ConfigCommandTest.php index 942d052d4..b8ab10e32 100644 --- a/tests/Composer/Test/Command/ConfigCommandTest.php +++ b/tests/Composer/Test/Command/ConfigCommandTest.php @@ -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"}}', ]; diff --git a/tests/Composer/Test/TestCase.php b/tests/Composer/Test/TestCase.php index fe0f9365b..567a72596 100644 --- a/tests/Composer/Test/TestCase.php +++ b/tests/Composer/Test/TestCase.php @@ -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));