1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00
This commit is contained in:
Jordi Boggiano 2022-08-17 15:20:07 +03:00 committed by GitHub
parent 6e205a0c84
commit 131da999ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
357 changed files with 5943 additions and 9174 deletions

View file

@ -40,11 +40,11 @@ class GitBitbucketDriverTest extends TestCase
$this->home = self::getUniqueTmpDirectory();
$this->config = new Config();
$this->config->merge(array(
'config' => array(
$this->config->merge([
'config' => [
'home' => $this->home,
),
));
],
]);
$this->httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')
->disableOriginalConstructor()
@ -60,7 +60,6 @@ class GitBitbucketDriverTest extends TestCase
/**
* @param array<string, mixed> $repoConfig
* @return GitBitbucketDriver
*
* @phpstan-param array{url: string}&array<string, mixed> $repoConfig
*/
@ -88,53 +87,53 @@ class GitBitbucketDriverTest extends TestCase
->method('get')
->with(
$url = 'https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner',
array()
[]
)
->willReturn(
new Response(array('url' => $url), 200, array(), '{"scm":"hg","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/tags"},"clone":[{"href":"https:\/\/user@bitbucket.org\/user\/repo","name":"https"},{"href":"ssh:\/\/hg@bitbucket.org\/user\/repo","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/user\/repo"}},"language":"php","created_on":"2015-02-18T16:22:24.688+00:00","updated_on":"2016-05-17T13:20:21.993+00:00","is_private":true,"has_issues":false}')
new Response(['url' => $url], 200, [], '{"scm":"hg","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/tags"},"clone":[{"href":"https:\/\/user@bitbucket.org\/user\/repo","name":"https"},{"href":"ssh:\/\/hg@bitbucket.org\/user\/repo","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/user\/repo"}},"language":"php","created_on":"2015-02-18T16:22:24.688+00:00","updated_on":"2016-05-17T13:20:21.993+00:00","is_private":true,"has_issues":false}')
);
$driver = $this->getDriver(array('url' => 'https://bitbucket.org/user/repo.git'));
$driver = $this->getDriver(['url' => 'https://bitbucket.org/user/repo.git']);
$driver->getRootIdentifier();
}
public function testDriver(): GitBitbucketDriver
{
$driver = $this->getDriver(array('url' => 'https://bitbucket.org/user/repo.git'));
$driver = $this->getDriver(['url' => 'https://bitbucket.org/user/repo.git']);
$urls = array(
$urls = [
'https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner',
'https://api.bitbucket.org/2.0/repositories/user/repo/refs/tags?pagelen=100&fields=values.name%2Cvalues.target.hash%2Cnext&sort=-target.date',
'https://api.bitbucket.org/2.0/repositories/user/repo/refs/branches?pagelen=100&fields=values.name%2Cvalues.target.hash%2Cvalues.heads%2Cnext&sort=-target.date',
'https://api.bitbucket.org/2.0/repositories/user/repo/src/main/composer.json',
'https://api.bitbucket.org/2.0/repositories/user/repo/commit/main?fields=date',
);
];
$this->httpDownloader->expects($this->any())
->method('get')
->withConsecutive(
array(
$urls[0], array(),
),
array(
$urls[1], array(),
),
array(
$urls[2], array(),
),
array(
$urls[3], array(),
),
array(
$urls[4], array(),
)
[
$urls[0], [],
],
[
$urls[1], [],
],
[
$urls[2], [],
],
[
$urls[3], [],
],
[
$urls[4], [],
]
)
->willReturnOnConsecutiveCalls(
new Response(array('url' => $urls[0]), 200, array(), '{"mainbranch": {"name": "main"}, "scm":"git","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/tags"},"clone":[{"href":"https:\/\/user@bitbucket.org\/user\/repo.git","name":"https"},{"href":"ssh:\/\/git@bitbucket.org\/user\/repo.git","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/user\/repo"}},"language":"php","created_on":"2015-02-18T16:22:24.688+00:00","updated_on":"2016-05-17T13:20:21.993+00:00","is_private":true,"has_issues":false}'),
new Response(array('url' => $urls[1]), 200, array(), '{"values":[{"name":"1.0.1","target":{"hash":"9b78a3932143497c519e49b8241083838c8ff8a1"}},{"name":"1.0.0","target":{"hash":"d3393d514318a9267d2f8ebbf463a9aaa389f8eb"}}]}'),
new Response(array('url' => $urls[2]), 200, array(), '{"values":[{"name":"main","target":{"hash":"937992d19d72b5116c3e8c4a04f960e5fa270b22"}}]}'),
new Response(array('url' => $urls[3]), 200, array(), '{"name": "user/repo","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "local@domain.tld"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}'),
new Response(array('url' => $urls[4]), 200, array(), '{"date": "2016-05-17T13:19:52+00:00"}')
new Response(['url' => $urls[0]], 200, [], '{"mainbranch": {"name": "main"}, "scm":"git","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/tags"},"clone":[{"href":"https:\/\/user@bitbucket.org\/user\/repo.git","name":"https"},{"href":"ssh:\/\/git@bitbucket.org\/user\/repo.git","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/user\/repo"}},"language":"php","created_on":"2015-02-18T16:22:24.688+00:00","updated_on":"2016-05-17T13:20:21.993+00:00","is_private":true,"has_issues":false}'),
new Response(['url' => $urls[1]], 200, [], '{"values":[{"name":"1.0.1","target":{"hash":"9b78a3932143497c519e49b8241083838c8ff8a1"}},{"name":"1.0.0","target":{"hash":"d3393d514318a9267d2f8ebbf463a9aaa389f8eb"}}]}'),
new Response(['url' => $urls[2]], 200, [], '{"values":[{"name":"main","target":{"hash":"937992d19d72b5116c3e8c4a04f960e5fa270b22"}}]}'),
new Response(['url' => $urls[3]], 200, [], '{"name": "user/repo","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "local@domain.tld"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}'),
new Response(['url' => $urls[4]], 200, [], '{"date": "2016-05-17T13:19:52+00:00"}')
);
$this->assertEquals(
@ -143,43 +142,43 @@ class GitBitbucketDriverTest extends TestCase
);
$this->assertEquals(
array(
[
'1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1',
'1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb',
),
],
$driver->getTags()
);
$this->assertEquals(
array(
[
'main' => '937992d19d72b5116c3e8c4a04f960e5fa270b22',
),
],
$driver->getBranches()
);
$this->assertEquals(
array(
[
'name' => 'user/repo',
'description' => 'test repo',
'license' => 'GPL',
'authors' => array(
array(
'authors' => [
[
'name' => 'Name',
'email' => 'local@domain.tld',
),
),
'require' => array(
],
],
'require' => [
'creator/package' => '^1.0',
),
'require-dev' => array(
],
'require-dev' => [
'phpunit/phpunit' => '~4.8',
),
],
'time' => '2016-05-17T13:19:52+00:00',
'support' => array(
'support' => [
'source' => 'https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=main',
),
],
'homepage' => 'https://bitbucket.org/user/repo',
),
],
$driver->getComposerInformation('main')
);
@ -188,7 +187,6 @@ class GitBitbucketDriverTest extends TestCase
/**
* @depends testDriver
* @param \Composer\Repository\Vcs\VcsDriverInterface $driver
*/
public function testGetParams(\Composer\Repository\Vcs\VcsDriverInterface $driver): void
{
@ -197,17 +195,17 @@ class GitBitbucketDriverTest extends TestCase
$this->assertEquals($url, $driver->getUrl());
$this->assertEquals(
array(
[
'type' => 'zip',
'url' => 'https://bitbucket.org/user/repo/get/reference.zip',
'reference' => 'reference',
'shasum' => '',
),
],
$driver->getDist('reference')
);
$this->assertEquals(
array('type' => 'git', 'url' => $url, 'reference' => 'reference'),
['type' => 'git', 'url' => $url, 'reference' => 'reference'],
$driver->getSource('reference')
);
}
@ -216,7 +214,7 @@ class GitBitbucketDriverTest extends TestCase
{
$this->expectException('\InvalidArgumentException');
$driver = $this->getDriver(array('url' => 'https://bitbucket.org/acme'));
$driver = $this->getDriver(['url' => 'https://bitbucket.org/acme']);
$driver->initialize();
}