Skip to content

Commit

Permalink
Merge remote-tracking branch 'mbaynton/composer-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Mar 28, 2020
2 parents 7d610d5 + 9b80251 commit b4f89de
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php

sudo: false

dist: trusty

git:
Expand All @@ -17,17 +15,25 @@ php:
- 7.3
- nightly

matrix:
env:
- DEPS=--prefer-lowest
- DEPS=

jobs:
include:
- dist: precise
php: 5.3
env: DEPS=
- dist: precise
php: 5.3
env: DEPS=--prefer-lowest
fast_finish: true
allow_failures:
- php: nightly

before_script:
- composer self-update
- composer install
- composer update $DEPS

script:
- composer test
- vendor/bin/composer test
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@
"roundcube/plugin-installer": "*"
},
"require": {
"composer-plugin-api": "^1.0"
"composer-plugin-api": "^1.0|^2.0"
},
"require-dev": {
"composer/composer": "1.0.*@dev",
"phpunit/phpunit": "^4.8.36"
"composer/composer": "1.0.0|2.0.*@dev",
"phpunit/phpunit": "^4.8.36",
"sebastian/comparator": ">= 1.2.4",
"symfony/process": ">= 2.3"
},
"scripts": {
"test": "phpunit"
Expand Down
28 changes: 9 additions & 19 deletions src/Composer/Installers/CakePHPInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,15 @@ protected function matchesCakeVersion($matcher, $version)
}

$repositoryManager = $this->composer->getRepositoryManager();
if ($repositoryManager) {
$repos = $repositoryManager->getLocalRepository();
if (!$repos) {
return false;
}
$cake3 = new $multiClass(array(
new $constraintClass($matcher, $version),
new $constraintClass('!=', '9999999-dev'),
));
$pool = new Pool('dev');
$pool->addRepository($repos);
$packages = $pool->whatProvides('cakephp/cakephp');
foreach ($packages as $package) {
$installed = new $constraintClass('=', $package->getVersion());
if ($cake3->matches($installed)) {
return true;
}
}
if (! $repositoryManager) {
return false;
}
return false;

$repos = $repositoryManager->getLocalRepository();
if (!$repos) {
return false;
}

return $repos->findPackage('cakephp/cakephp', new $constraintClass($matcher, $version)) !== null;
}
}
20 changes: 13 additions & 7 deletions tests/Composer/Installers/Test/CakePHPInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,20 @@ public function testInflectPackageVars()
public function testGetLocations() {
$package = new RootPackage('CamelCased', '1.0', '1.0');
$composer = $this->composer;

$io = $this->getMock('Composer\IO\IOInterface');
$config = $this->getMock('Composer\Config');

// Simultaneous support for Composer 1 and 2
$constructorArg3 = null;
$reflectorClass = new \ReflectionClass( '\Composer\Repository\RepositoryManager');
if ($reflectorClass->getConstructor()->getNumberOfRequiredParameters() == 3) {
$constructorArg3 = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
}
$rm = new RepositoryManager(
$this->getMock('Composer\IO\IOInterface'),
$this->getMock('Composer\Config')
$io,
$config,
$constructorArg3
);
$composer->setRepositoryManager($rm);
$installer = new CakePHPInstaller($package, $composer);
Expand All @@ -83,11 +94,6 @@ public function testGetLocations() {
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);

// special handling for 2.x versions when 3.x is still in development
$this->setCakephpVersion($rm, 'dev-master');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);

$this->setCakephpVersion($rm, '>=2.5');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
Expand Down

0 comments on commit b4f89de

Please sign in to comment.