1
0
Fork 0

Fix show --platform regression failing if no composer.json exists, fixes #11046

pull/11057/head
Jordi Boggiano 2022-09-13 14:49:25 +02:00
parent 9bb436ec28
commit 4164b30236
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 20 additions and 1 deletions

View File

@ -677,7 +677,12 @@ EOT
*/
protected function getRootRequires(): array
{
$rootPackage = $this->requireComposer()->getPackage();
$composer = $this->tryComposer();
if ($composer === null) {
return [];
}
$rootPackage = $composer->getPackage();
return array_map(
'strtolower',

View File

@ -192,6 +192,20 @@ outdated/patch 1.0.0 <highlight>! 1.0.1</highlight>',
}
}
public function testShowPlatformWorksWithoutComposerJson(): void
{
$this->initTempComposer([]);
unlink('./composer.json');
unlink('./auth.json');
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'show', '-p' => true]);
$output = trim($appTester->getDisplay(true));
foreach (Regex::matchAll('{^(\w+)}m', $output)->matches as $m) {
self::assertTrue(PlatformRepository::isPlatformPackage((string) $m[1]));
}
}
public function testOutdatedWithZeroMajor(): void
{
$this->initTempComposer([