Skip to content

Commit 4aab26a

Browse files
Require Composer 1.4
1 parent 1ca5831 commit 4aab26a

File tree

4 files changed

+105
-93
lines changed

4 files changed

+105
-93
lines changed

Tests/Repository/Vcs/GitBitbucketDriverTest.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public function testPublicRepositoryWithComposer($type, $filename)
6666
{
6767
$repoBaseUrl = 'https://bitbucket.org/composer-test/repo-name';
6868
$repoUrl = $repoBaseUrl.'.git';
69-
$repoApiUrl = 'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name';
7069
$identifier = 'v0.0.0';
7170
$sha = 'SOMESHA';
7271

@@ -79,19 +78,30 @@ public function testPublicRepositoryWithComposer($type, $filename)
7978
->setConstructorArgs(array($io))
8079
->getMock();
8180

82-
$remoteFilesystem->expects($this->at(0))
83-
->method('getContents')
84-
->with($this->equalTo('bitbucket.org'), $this->equalTo($this->getScheme($repoApiUrl)), $this->equalTo(false))
85-
->will($this->returnValue($this->createJsonComposer(array('main_branch' => 'test_master'))));
86-
87-
$remoteFilesystem->expects($this->at(1))
81+
$remoteFilesystem->expects($this->any())
8882
->method('getContents')
89-
->with(
90-
$this->equalTo('bitbucket.org'),
91-
$this->equalTo($repoApiUrl.'/src/'.$identifier.'/'.$filename),
92-
$this->equalTo(false)
83+
->withConsecutive(
84+
array(
85+
'bitbucket.org',
86+
'https://api.bitbucket.org/2.0/repositories/composer-test/repo-name?fields=-project%2C-owner',
87+
false,
88+
),
89+
array(
90+
'bitbucket.org',
91+
'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name/main-branch',
92+
false,
93+
),
94+
array(
95+
'bitbucket.org',
96+
'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name/src/v0.0.0/'.$filename,
97+
false,
98+
)
9399
)
94-
->will($this->returnValue($this->createApiJsonWithRepoData(array())));
100+
->willReturnOnConsecutiveCalls(
101+
'{"scm":"git","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/composer-test\/repo-name\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/composer-test\/repo-name\/refs\/tags"},"clone":[{"href":"https:\/\/[email protected]\/composer-test\/repo-name.git","name":"https"},{"href":"ssh:\/\/[email protected]\/composer-test\/repo-name.git","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/composer-test\/repo-name"}},"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}',
102+
'{"name": "test_master"}',
103+
'{"name": "composer-test/repo-name","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "[email protected]"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}'
104+
);
95105

96106
$repoConfig = array(
97107
'url' => $repoUrl,
@@ -104,7 +114,6 @@ public function testPublicRepositoryWithComposer($type, $filename)
104114

105115
$driver = new GitBitbucketDriver($repoConfig, $io, $this->config, null, $remoteFilesystem);
106116
$driver->initialize();
107-
$this->setAttribute($driver, 'tags', array($identifier => $sha));
108117

109118
$this->assertEquals('test_master', $driver->getRootIdentifier());
110119

Tests/Repository/Vcs/HgBitbucketDriverTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,30 @@ public function testPublicRepositoryWithComposer($type, $filename)
7777
->setConstructorArgs(array($io))
7878
->getMock();
7979

80-
$remoteFilesystem->expects($this->at(0))
81-
->method('getContents')
82-
->with($this->equalTo('bitbucket.org'), $this->equalTo($this->getScheme('https://bitbucket.org/api/1.0/repositories/composer-test/repo-name/tags')), $this->equalTo(false))
83-
->will($this->returnValue($this->createJsonComposer(array('tip' => array('raw_node' => 'test_master')))));
84-
85-
$remoteFilesystem->expects($this->at(1))
80+
$remoteFilesystem->expects($this->any())
8681
->method('getContents')
87-
->with($this->equalTo('bitbucket.org'), $this->equalTo($this->getScheme($repoUrl).'/raw/'.$identifier.'/'.$filename), $this->equalTo(false))
88-
->will($this->returnValue($this->createJsonComposer(array())));
82+
->withConsecutive(
83+
array(
84+
'bitbucket.org',
85+
'https://api.bitbucket.org/2.0/repositories/composer-test/repo-name?fields=-project%2C-owner',
86+
false,
87+
),
88+
array(
89+
'bitbucket.org',
90+
'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name/main-branch',
91+
false,
92+
),
93+
array(
94+
'bitbucket.org',
95+
'https://bitbucket.org/composer-test/repo-name/raw/v0.0.0/'.$filename,
96+
false,
97+
)
98+
)
99+
->willReturnOnConsecutiveCalls(
100+
'{"scm":"hg","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/composer-test\/repo-name\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/composer-test\/repo-name\/refs\/tags"},"clone":[{"href":"https:\/\/[email protected]\/composer-test\/repo-name","name":"https"}],"html":{"href":"https:\/\/bitbucket.org\/composer-test\/repo-name"}},"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}',
101+
'{"name": "test_master"}',
102+
'{"name": "composer-test/repo-name","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "[email protected]"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}'
103+
);
89104

90105
$repoConfig = array(
91106
'url' => $repoUrl,
@@ -167,21 +182,6 @@ protected function setAttribute($object, $attribute, $value)
167182
$attr->setValue($object, $value);
168183
}
169184

170-
/**
171-
* Creates the json composer content.
172-
*
173-
* @param array $content The composer content
174-
* @param string $name The name of repository
175-
*
176-
* @return string The json content
177-
*/
178-
protected function createJsonComposer(array $content, $name = 'repo-name')
179-
{
180-
return json_encode(array_merge_recursive($content, array(
181-
'name' => $name,
182-
)));
183-
}
184-
185185
/**
186186
* Get the url with https or http protocol depending on SSL support.
187187
*

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"composer-plugin-api": "^1.0"
1717
},
1818
"require-dev": {
19-
"composer/composer": "^1.3.0"
19+
"composer/composer": "^1.4.0"
2020
},
2121
"autoload": {
2222
"psr-4": {

0 commit comments

Comments
 (0)