Browse Source

Add failing test case

Chris Smith 10 years ago
parent
commit
2e40f5f586

+ 19 - 0
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)

+ 23 - 0
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"
+                    }
+                }
+            }
+        }
+    }
+}

+ 15 - 0
tests/Composer/Test/InstallerTest.php

@@ -283,6 +283,21 @@ class InstallerTest extends TestCase
                     $message = $match['test'];
                     $message = $match['test'];
                     $condition = !empty($match['condition']) ? $match['condition'] : null;
                     $condition = !empty($match['condition']) ? $match['condition'] : null;
                     $composer = JsonFile::parseJson($match['composer']);
                     $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'])) {
                     if (!empty($match['lock'])) {
                         $lock = JsonFile::parseJson($match['lock']);
                         $lock = JsonFile::parseJson($match['lock']);
                         if (!isset($lock['hash'])) {
                         if (!isset($lock['hash'])) {