From 43093d0eeb3cbae7d7edd430de50e76ef781f07b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 28 Aug 2020 14:50:28 +0200 Subject: [PATCH] Add tests for edge cases of packages providing names which exist as real packages --- ...th-other-version-of-provided-conflict.test | 56 +++++++++++++++++++ ...th-other-version-of-provided-indirect.test | 54 ++++++++++++++++++ ...gether-with-other-version-of-provided.test | 46 +++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-conflict.test create mode 100644 tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-indirect.test create mode 100644 tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided.test diff --git a/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-conflict.test b/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-conflict.test new file mode 100644 index 000000000..b718a3a7d --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-conflict.test @@ -0,0 +1,56 @@ +--TEST-- +A root requirement for a name exists as well as a dependency's requirement for the same name but in a different version. +Since the root requirement does not allow the dependency's requirement to be installed, this conflicts. + +The difference between this test and the one which does not conflict is that here the root requirement could only be +satisfied with the provided package but would conflict with the actual package by the given name. +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { + "name": "foo/provider", + "provide": { + "foo/original": "3.0.0" + }, + "version": "1.0.0" + }, + { + "name": "foo/original", + "version": "1.0.0" + }, + { + "name": "foo/requirer", + "require": { + "foo/original": "1.0.0" + }, + "version": "1.0.0" + } + ] + } + ], + "require": { + "foo/original": "3.0.0", + "foo/provider": "1.0.0", + "foo/requirer": "1.0.0" + } +} + +--RUN-- +update + +--EXPECT-EXIT-CODE-- +2 + +--EXPECT-OUTPUT-- +Loading composer repositories with package information +Updating dependencies +Your requirements could not be resolved to an installable set of packages. + + Problem 1 + - Root composer.json requires foo/requirer 1.0.0 -> satisfiable by foo/requirer[1.0.0]. + - foo/requirer 1.0.0 requires foo/original 1.0.0 -> found foo/original[1.0.0] but it conflicts with your root composer.json require (3.0.0). + +--EXPECT-- diff --git a/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-indirect.test b/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-indirect.test new file mode 100644 index 000000000..c9e629ce3 --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided-indirect.test @@ -0,0 +1,54 @@ +--TEST-- +This is a variant of the test provider-gets-picked-together-with-other-version-of-provided-conflict.test which differs +in so far as that the root requirements were all moved into a package which now allows the combination to succeed. + +Only root requirements strictly limit compatibility with versions if a package by a provided name also actually exists. +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { + "name": "foo/root", + "require": { + "foo/original": "3.0.0", + "foo/provider": "1.0.0", + "foo/requirer": "1.0.0" + }, + "version": "1.0.0" + }, + { + "name": "foo/provider", + "provide": { + "foo/original": "3.0.0" + }, + "version": "1.0.0" + }, + { + "name": "foo/original", + "version": "1.0.0" + }, + { + "name": "foo/requirer", + "require": { + "foo/original": "1.0.0" + }, + "version": "1.0.0" + } + ] + } + ], + "require": { + "foo/root": "1.0.0" + } +} + +--RUN-- +update + +--EXPECT-- +Installing foo/original (1.0.0) +Installing foo/provider (1.0.0) +Installing foo/requirer (1.0.0) +Installing foo/root (1.0.0) diff --git a/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided.test b/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided.test new file mode 100644 index 000000000..699e26539 --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/provider-gets-picked-together-with-other-version-of-provided.test @@ -0,0 +1,46 @@ +--TEST-- +A root requirement for a name exists as well as a dependency's requirement for the same name but in a different version. +The root requirement is satisfied by the actual package by that name in that version. The dependency's requirement can +be satisfied by another package which provides the name in the other version. This will result in all packages being +installed as the provider does not conflict with the actual package and all requirements can be met. +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { + "name": "foo/provider", + "provide": { + "foo/original": "3.0.0" + }, + "version": "1.0.0" + }, + { + "name": "foo/original", + "version": "1.0.0" + }, + { + "name": "foo/requirer", + "require": { + "foo/original": "3.0.0" + }, + "version": "1.0.0" + } + ] + } + ], + "require": { + "foo/original": "1.0.0", + "foo/provider": "1.0.0", + "foo/requirer": "1.0.0" + } +} + +--RUN-- +update + +--EXPECT-- +Installing foo/original (1.0.0) +Installing foo/provider (1.0.0) +Installing foo/requirer (1.0.0)