diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/mirrored-path-repo/composer.json b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/mirrored-path-repo/composer.json new file mode 100644 index 000000000..5e09733ec --- /dev/null +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/mirrored-path-repo/composer.json @@ -0,0 +1,8 @@ +{ + "name": "mirrored/path-pkg", + "version": "2.0.0", + "require": { + "mirrored/transitive": "2.*", + "mirrored/transitive2": "2.*" + } +} diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-unfixes-path-repos-always-but-not-their-transitive-deps.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-unfixes-path-repos-always-but-not-their-transitive-deps.test new file mode 100644 index 000000000..8e7c8068f --- /dev/null +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-unfixes-path-repos-always-but-not-their-transitive-deps.test @@ -0,0 +1,79 @@ +--TEST-- +Partially updating one root requirement with transitive deps fully updates transitive deps, and always updates symlinked path repos, but not the transitive deps of the path repos. + +--REQUEST-- +{ + "require": { + "root/update": "*", + "symlinked/path-pkg": "*", + "mirrored/path-pkg": "*" + }, + "locked": [ + {"name": "root/update", "version": "1.0.1", "require": {"symlinked/transitive2": ">=1.0.1", "mirrored/transitive2": ">=1.0.1"}}, + {"name": "symlinked/transitive", "version": "1.0.0"}, + {"name": "symlinked/transitive2", "version": "1.0.0"}, + {"name": "mirrored/transitive", "version": "1.0.0"}, + {"name": "mirrored/transitive2", "version": "1.0.0"}, + { + "name": "symlinked/path-pkg", + "version": "1.0.0", + "require": { + "symlinked/transitive": "1.*", + "symlinked/transitive2": "1.*" + }, + "dist": {"type": "path", "url": "./symlinked-path-repo", "reference": "abcd"}, "transport-options": {} + }, + { + "name": "mirrored/path-pkg", + "version": "1.0.0", + "require": { + "mirrored/transitive": "1.*", + "mirrored/transitive2": "1.*" + }, + "dist": {"type": "path", "url": "./mirrored-path-repo", "reference": "abcd"}, "transport-options": {"symlink": false} + } + ], + "allowList": [ + "root/update" + ], + "allowTransitiveDeps": true +} + +--FIXED-- +[ +] + +--PACKAGE-REPOS-- +[ + {"type": "path", "url": "./symlinked-path-repo"}, + {"type": "path", "url": "./mirrored-path-repo", "options": {"symlink": false}}, + [ + {"name": "root/update", "version": "1.0.4", "require": {"symlinked/transitive2": ">=1.0.1", "mirrored/transitive2": ">=1.0.1"}}, + {"name": "symlinked/transitive", "version": "1.0.0"}, + {"name": "symlinked/transitive", "version": "1.0.1"}, + {"name": "symlinked/transitive", "version": "2.0.2"}, + {"name": "symlinked/transitive2", "version": "1.0.0"}, + {"name": "symlinked/transitive2", "version": "1.0.3"}, + {"name": "symlinked/transitive2", "version": "2.0.4"}, + {"name": "mirrored/transitive", "version": "1.0.0"}, + {"name": "mirrored/transitive", "version": "1.0.5"}, + {"name": "mirrored/transitive", "version": "2.0.6"}, + {"name": "mirrored/transitive2", "version": "1.0.0"}, + {"name": "mirrored/transitive2", "version": "1.0.7"}, + {"name": "mirrored/transitive2", "version": "2.0.8"} + ] +] + +--EXPECT-- +[ + "symlinked/transitive-1.0.0.0 (locked)", + "mirrored/transitive-1.0.0.0 (locked)", + "mirrored/path-pkg-1.0.0.0 (locked)", + "symlinked/path-pkg-2.0.0.0", + "root/update-1.0.4.0", + "symlinked/transitive2-1.0.3.0", + "symlinked/transitive2-2.0.4.0", + "mirrored/transitive2-1.0.0.0", + "mirrored/transitive2-1.0.7.0", + "mirrored/transitive2-2.0.8.0" +] diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/symlinked-path-repo/composer.json b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/symlinked-path-repo/composer.json new file mode 100644 index 000000000..4f4ff14e5 --- /dev/null +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/symlinked-path-repo/composer.json @@ -0,0 +1,8 @@ +{ + "name": "symlinked/path-pkg", + "version": "2.0.0", + "require": { + "symlinked/transitive": "2.*", + "symlinked/transitive2": "2.*" + } +} diff --git a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php index 3eb0ebc41..6be0d3016 100644 --- a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php @@ -15,6 +15,7 @@ namespace Composer\Test\DependencyResolver; use Composer\DependencyResolver\DefaultPolicy; use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\PoolOptimizer; +use Composer\Config; use Composer\IO\NullIO; use Composer\Repository\ArrayRepository; use Composer\Repository\FilterRepository; @@ -25,6 +26,7 @@ use Composer\Package\AliasPackage; use Composer\Json\JsonFile; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Version\VersionParser; +use Composer\Repository\RepositoryFactory; use Composer\Repository\RepositorySet; use Composer\Test\TestCase; @@ -57,7 +59,7 @@ class PoolBuilderTest extends TestCase $rootAliases[$index]['alias_normalized'] = $parser->normalize($alias['alias']); } - $loader = new ArrayLoader(); + $loader = new ArrayLoader(null, true); $packageIds = array(); $loadPackage = function ($data) use ($loader, &$packageIds) { /** @var ?int $id */ @@ -79,8 +81,17 @@ class PoolBuilderTest extends TestCase return $pkg; }; + $oldCwd = getcwd(); + chdir(__DIR__.'/Fixtures/poolbuilder/'); + $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $rootReferences); foreach ($packageRepos as $packages) { + if (isset($packages['type'])) { + $repo = RepositoryFactory::createRepo(new NullIO, new Config(false), $packages); + $repositorySet->addRepository($repo); + continue; + } + $repo = new ArrayRepository(); if (isset($packages['canonical']) || isset($packages['only']) || isset($packages['exclude'])) { $options = $packages; @@ -142,6 +153,8 @@ class PoolBuilderTest extends TestCase $result[] = $pool->packageById($i); } + chdir($oldCwd); + return array_map(function (BasePackage $package) use ($packageIds) { if ($id = array_search($package, $packageIds, true)) { return $id;