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:
parent
5d2d513f97
commit
685a2e6be2
6 changed files with 116 additions and 39 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue