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

Composer support string (#11386)

* GitHubDriver: fix support is set to string

* GitLabDriver: fix support is set to string

* BitbucketDriver: fix support is set to string

* Fix PHPStan
This commit is contained in:
Stephan 2023-03-20 19:18:19 +00:00 committed by GitHub
parent 5d2d513f97
commit 685a2e6be2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 116 additions and 39 deletions

View file

@ -244,6 +244,22 @@ JSON;
$this->assertEquals($url, $driver->getUrl());
}
public function testInvalidSupportData(): void
{
$driver = $this->testInitialize($repoUrl = 'https://gitlab.com/mygroup/myproject', 'https://gitlab.com/api/v4/projects/mygroup%2Fmyproject');
$this->setAttribute($driver, 'branches', ['main' => 'SOMESHA']);
$this->setAttribute($driver, 'tags', []);
$this->httpDownloader->expects([
['url' => 'https://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/files/composer%2Ejson/raw?ref=SOMESHA', 'body' => '{"support": "'.$repoUrl.'" }'],
], true);
$data = $driver->getComposerInformation('main');
$this->assertIsArray($data);
$this->assertSame('https://gitlab.com/mygroup/myproject/-/tree/main', $data['support']['source']);
}
public function testGetDist(): void
{
$driver = $this->testInitialize('https://gitlab.com/mygroup/myproject', 'https://gitlab.com/api/v4/projects/mygroup%2Fmyproject');
@ -631,4 +647,15 @@ JSON;
$driver->initialize();
$this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'Repository URL matches config request for http not git');
}
/**
* @param object $object
* @param mixed $value
*/
protected function setAttribute($object, string $attribute, $value): void
{
$attr = new \ReflectionProperty($object, $attribute);
$attr->setAccessible(true);
$attr->setValue($object, $value);
}
}