1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

GitHubDriver: better handle empty composer.json file (#11552)

This commit is contained in:
Stephan 2023-07-21 10:09:32 +01:00 committed by GitHub
parent 8f49166ec6
commit cf8ea3c70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -401,6 +401,34 @@ class GitHubDriverTest extends TestCase
];
}
public function testGetEmptyFileContent(): void
{
$repoUrl = 'http://github.com/composer/packagist';
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->any())
->method('isInteractive')
->will($this->returnValue(true));
$httpDownloader = $this->getHttpDownloaderMock($io, $this->config);
$httpDownloader->expects(
[
['url' => 'https://api.github.com/repos/composer/packagist', 'body' => '{"master_branch": "test_master", "owner": {"login": "composer"}, "name": "packagist", "archived": true}'],
['url' => 'https://api.github.com/repos/composer/packagist/contents/composer.json?ref=main', 'body' => '{"encoding":"base64","content":""}'],
],
true
);
$repoConfig = [
'url' => $repoUrl,
];
$gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, $this->getProcessExecutorMock());
$gitHubDriver->initialize();
$this->assertSame('', $gitHubDriver->getFileContent('composer.json', 'main'));
}
/**
* @param string|object $object
* @param mixed $value