diff --git a/tests/Composer/Test/Fixtures/installer/install-branch-alias-composer-repo.test b/tests/Composer/Test/Fixtures/installer/install-branch-alias-composer-repo.test new file mode 100644 index 000000000..bad64fc7d --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/install-branch-alias-composer-repo.test @@ -0,0 +1,19 @@ +--TEST-- +Installing branch aliased package from a Composer repository. +--COMPOSER-- +{ + "repositories": [ + { + "type": "composer", + "url": "file://install-branch-alias-composer-repo" + } + ], + "require": { + "a/a": "3.2.*@dev" + } +} +--RUN-- +install +--EXPECT-- +Installing a/a (dev-foobar abcdef0) +Marking a/a (3.2.x-dev abcdef0) as installed, alias of a/a (dev-foobar abcdef0) diff --git a/tests/Composer/Test/Fixtures/installer/install-branch-alias-composer-repo/packages.json b/tests/Composer/Test/Fixtures/installer/install-branch-alias-composer-repo/packages.json new file mode 100644 index 000000000..d51c0be9f --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/install-branch-alias-composer-repo/packages.json @@ -0,0 +1,23 @@ +{ + "packages": { + "a/a": { + "dev-foobar": { + "name": "a/a", + "version": "dev-foobar", + "version_normalized": "dev-foobar", + "source": { + "type": "git", + "url": "git@example.com:repo.git", + "reference": "abcdef0000000000000000000000000000000000" + }, + "time": "2014-11-13 11:52:12", + "type": "library", + "extra": { + "branch-alias": { + "dev-foobar": "3.2.x-dev" + } + } + } + } + } +} diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 40dd03313..ee306a818 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -283,6 +283,21 @@ class InstallerTest extends TestCase $message = $match['test']; $condition = !empty($match['condition']) ? $match['condition'] : null; $composer = JsonFile::parseJson($match['composer']); + + if (isset($composer['repositories'])) { + foreach ($composer['repositories'] as &$repo) { + if ($repo['type'] !== 'composer') { + continue; + } + + if (preg_match('{^file://[^/]}', $repo['url'])) { + $repo['url'] = "file://${fixturesDir}/" . substr($repo['url'], 7); + } + + unset($repo); + } + } + if (!empty($match['lock'])) { $lock = JsonFile::parseJson($match['lock']); if (!isset($lock['hash'])) {