Skip to content

Commit

Permalink
Require Composer 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
francoispluchino committed Mar 17, 2017
1 parent 1ca5831 commit 4aab26a
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 93 deletions.
35 changes: 22 additions & 13 deletions Tests/Repository/Vcs/GitBitbucketDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function testPublicRepositoryWithComposer($type, $filename)
{
$repoBaseUrl = 'https://bitbucket.org/composer-test/repo-name';
$repoUrl = $repoBaseUrl.'.git';
$repoApiUrl = 'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name';
$identifier = 'v0.0.0';
$sha = 'SOMESHA';

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

$remoteFilesystem->expects($this->at(0))
->method('getContents')
->with($this->equalTo('bitbucket.org'), $this->equalTo($this->getScheme($repoApiUrl)), $this->equalTo(false))
->will($this->returnValue($this->createJsonComposer(array('main_branch' => 'test_master'))));

$remoteFilesystem->expects($this->at(1))
$remoteFilesystem->expects($this->any())
->method('getContents')
->with(
$this->equalTo('bitbucket.org'),
$this->equalTo($repoApiUrl.'/src/'.$identifier.'/'.$filename),
$this->equalTo(false)
->withConsecutive(
array(
'bitbucket.org',
'https://api.bitbucket.org/2.0/repositories/composer-test/repo-name?fields=-project%2C-owner',
false,
),
array(
'bitbucket.org',
'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name/main-branch',
false,
),
array(
'bitbucket.org',
'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name/src/v0.0.0/'.$filename,
false,
)
)
->will($this->returnValue($this->createApiJsonWithRepoData(array())));
->willReturnOnConsecutiveCalls(
'{"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:\/\/user@bitbucket.org\/composer-test\/repo-name.git","name":"https"},{"href":"ssh:\/\/git@bitbucket.org\/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}',
'{"name": "test_master"}',
'{"name": "composer-test/repo-name","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "local@domain.tld"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}'
);

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

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

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

Expand Down
46 changes: 23 additions & 23 deletions Tests/Repository/Vcs/HgBitbucketDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,30 @@ public function testPublicRepositoryWithComposer($type, $filename)
->setConstructorArgs(array($io))
->getMock();

$remoteFilesystem->expects($this->at(0))
->method('getContents')
->with($this->equalTo('bitbucket.org'), $this->equalTo($this->getScheme('https://bitbucket.org/api/1.0/repositories/composer-test/repo-name/tags')), $this->equalTo(false))
->will($this->returnValue($this->createJsonComposer(array('tip' => array('raw_node' => 'test_master')))));

$remoteFilesystem->expects($this->at(1))
$remoteFilesystem->expects($this->any())
->method('getContents')
->with($this->equalTo('bitbucket.org'), $this->equalTo($this->getScheme($repoUrl).'/raw/'.$identifier.'/'.$filename), $this->equalTo(false))
->will($this->returnValue($this->createJsonComposer(array())));
->withConsecutive(
array(
'bitbucket.org',
'https://api.bitbucket.org/2.0/repositories/composer-test/repo-name?fields=-project%2C-owner',
false,
),
array(
'bitbucket.org',
'https://api.bitbucket.org/1.0/repositories/composer-test/repo-name/main-branch',
false,
),
array(
'bitbucket.org',
'https://bitbucket.org/composer-test/repo-name/raw/v0.0.0/'.$filename,
false,
)
)
->willReturnOnConsecutiveCalls(
'{"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:\/\/user@bitbucket.org\/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}',
'{"name": "test_master"}',
'{"name": "composer-test/repo-name","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "local@domain.tld"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}'
);

$repoConfig = array(
'url' => $repoUrl,
Expand Down Expand Up @@ -167,21 +182,6 @@ protected function setAttribute($object, $attribute, $value)
$attr->setValue($object, $value);
}

/**
* Creates the json composer content.
*
* @param array $content The composer content
* @param string $name The name of repository
*
* @return string The json content
*/
protected function createJsonComposer(array $content, $name = 'repo-name')
{
return json_encode(array_merge_recursive($content, array(
'name' => $name,
)));
}

/**
* Get the url with https or http protocol depending on SSL support.
*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"composer-plugin-api": "^1.0"
},
"require-dev": {
"composer/composer": "^1.3.0"
"composer/composer": "^1.4.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 4aab26a

Please sign in to comment.