diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-do-not-load-from-repos.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-do-not-load-from-repos.test index 0abc4a67e..976587e5b 100644 --- a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-do-not-load-from-repos.test +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-do-not-load-from-repos.test @@ -3,8 +3,10 @@ Fixed packages do not get loaded from the repos --REQUEST-- { - "some/pkg": "*", - "root/req": "*" + "require": { + "some/pkg": "*", + "root/req": "*" + } } --FIXED-- diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-replaced-do-not-load-from-repos.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-replaced-do-not-load-from-repos.test index 8006fc8db..bc403f83d 100644 --- a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-replaced-do-not-load-from-repos.test +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/fixed-packages-replaced-do-not-load-from-repos.test @@ -3,8 +3,10 @@ Packages replaced by fixed packages do not get loaded from the repos --REQUEST-- { - "some/pkg": "*", - "root/req": "*" + "require": { + "some/pkg": "*", + "root/req": "*" + } } --FIXED-- diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-transitive-deps-no-root-unfix.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-transitive-deps-no-root-unfix.test new file mode 100644 index 000000000..484d71dfe --- /dev/null +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-transitive-deps-no-root-unfix.test @@ -0,0 +1,42 @@ +--TEST-- +Partially updating one root requirement with transitive deps without root requirements keeps the other root requirement fixed. + +--REQUEST-- +{ + "require": { + "root/update": "*", + "root/fix": "*" + }, + "locked": [ + {"name": "root/update", "version": "1.0.1", "require": {"dep/dep": "1.*"}, "id": 1}, + {"name": "dep/dep", "version": "1.0.2", "require": {"root/fix": "1.*"}, "id": 2}, + {"name": "root/fix", "version": "1.0.3", "id": 3} + ], + "allowList": [ + "root/update" + ], + "allowTransitiveDepsNoRootRequire": true +} + +--FIXED-- +[ +] + +--PACKAGES-- +[ + {"name": "root/update", "version": "1.0.4", "require": {"dep/dep": "1.*"}}, + {"name": "root/update", "version": "1.0.5", "require": {"dep/dep": "2.*"}}, + {"name": "root/fix", "version": "1.0.6"}, + {"name": "root/fix", "version": "2.0.7"}, + {"name": "dep/dep", "version": "1.0.8", "require": {"root/fix": "1.*"}}, + {"name": "dep/dep", "version": "2.0.9", "require": {"root/fix": "2.*"}} +] + +--EXPECT-- +[ + 3, + "root/update-1.0.4.0", + "root/update-1.0.5.0", + "dep/dep-1.0.8.0", + "dep/dep-2.0.9.0" +] diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-transitive-deps-unfix.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-transitive-deps-unfix.test new file mode 100644 index 000000000..7e0cf2d2d --- /dev/null +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update-transitive-deps-unfix.test @@ -0,0 +1,43 @@ +--TEST-- +Partially updating one root requirement with transitive deps fully updates another one too. + +--REQUEST-- +{ + "require": { + "root/update": "*", + "root/dep": "*" + }, + "locked": [ + {"name": "root/update", "version": "1.0.1", "require": {"dep/dep": "1.*"}, "id": 1}, + {"name": "dep/dep", "version": "1.0.2", "require": {"root/dep": "1.*"}, "id": 2}, + {"name": "root/dep", "version": "1.0.3", "id": 3} + ], + "allowList": [ + "root/update" + ], + "allowTransitiveDeps": true +} + +--FIXED-- +[ +] + +--PACKAGES-- +[ + {"name": "root/update", "version": "1.0.4", "require": {"dep/dep": "1.*"}}, + {"name": "root/update", "version": "1.0.5", "require": {"dep/dep": "2.*"}}, + {"name": "root/dep", "version": "1.0.6"}, + {"name": "root/dep", "version": "2.0.7"}, + {"name": "dep/dep", "version": "1.0.8", "require": {"root/dep": "1.*"}}, + {"name": "dep/dep", "version": "2.0.9", "require": {"root/dep": "2.*"}} +] + +--EXPECT-- +[ + "root/update-1.0.4.0", + "root/update-1.0.5.0", + "dep/dep-1.0.8.0", + "dep/dep-2.0.9.0", + "root/dep-1.0.6.0", + "root/dep-2.0.7.0" +] diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update.test new file mode 100644 index 000000000..af6c5c689 --- /dev/null +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/partial-update.test @@ -0,0 +1,37 @@ +--TEST-- +Partially updating a root requirement without deps, still selects a new dependency if the update results in a replacement missing for another locked package. + +--REQUEST-- +{ + "require": { + "some/pkg": "*", + "root/req": "*" + }, + "locked": [ + {"name": "some/pkg", "version": "1.0.3", "replace": {"dep/dep": "2.1.0"}, "id": 1}, + {"name": "root/req", "version": "1.0.0", "require": {"dep/dep": "2.*"}, "id": 2} + ], + "allowList": [ + "some/pkg" + ] +} + +--FIXED-- +[ +] + +--PACKAGES-- +[ + {"name": "some/pkg", "version": "1.0.4"}, + {"name": "root/req", "version": "1.0.0", "require": {"dep/dep": "2.*"}}, + {"name": "root/req", "version": "2.0.0", "require": {"dep/dep": "3.*"}}, + {"name": "dep/dep", "version": "2.3.4"}, + {"name": "dep/dep", "version": "3.0.1"} +] + +--EXPECT-- +[ + 2, + "some/pkg-1.0.4.0", + "dep/dep-2.3.4.0" +] diff --git a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/stability-flags-take-over-minimum-stability-and-filter-packages.test b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/stability-flags-take-over-minimum-stability-and-filter-packages.test index 5a6ca8f2f..b273753d2 100644 --- a/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/stability-flags-take-over-minimum-stability-and-filter-packages.test +++ b/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/stability-flags-take-over-minimum-stability-and-filter-packages.test @@ -18,8 +18,10 @@ Stability flags apply --REQUEST-- { - "flagged/pkg": "*", - "default/pkg": "*" + "require": { + "flagged/pkg": "*", + "default/pkg": "*" + } } --PACKAGES-- diff --git a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php index 647ee2c2d..f02b99fc9 100644 --- a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php @@ -73,14 +73,30 @@ class PoolBuilderTest extends TestCase $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases); $repositorySet->addRepository($repo = new ArrayRepository()); + $repositorySet->addRepository($lockedRepo = new LockArrayRepository()); foreach ($packages as $package) { $repo->addPackage($loadPackage($package)); } - $request = new Request(); - foreach ($requestData as $package => $constraint) { + if (isset($requestData['locked'])) { + foreach ($requestData['locked'] as $package) { + $lockedRepo->addPackage($loadPackage($package)); + } + } + $request = new Request($lockedRepo); + foreach ($requestData['require'] as $package => $constraint) { $request->requireName($package, $parser->parseConstraints($constraint)); } + if (isset($requestData['allowList'])) { + $transitiveDeps = Request::UPDATE_ONLY_LISTED; + if (isset($requestData['allowTransitiveDepsNoRootRequire']) && $requestData['allowTransitiveDepsNoRootRequire']) { + $transitiveDeps = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE; + } + if (isset($requestData['allowTransitiveDeps']) && $requestData['allowTransitiveDeps']) { + $transitiveDeps = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS; + } + $request->setUpdateAllowList(array_flip($requestData['allowList']), $transitiveDeps); + } foreach ($fixed as $fixedPackage) { $request->fixPackage($loadPackage($fixedPackage));