From 1dbc4136d99593685a3efb61cfeeddddca8453b9 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 5 Jan 2023 21:03:38 +0100 Subject: [PATCH 1/3] Enhancement: Require composer/semver --- composer.json | 1 + composer.lock | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8ceddf5f..3667bb63 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "justinrainbow/json-schema": "^5.2.12" }, "require-dev": { + "composer/semver": "^3.0.0", "ergebnis/data-provider": "^1.3.0", "ergebnis/license": "^2.1.0", "ergebnis/php-cs-fixer-config": "^5.2.0", diff --git a/composer.lock b/composer.lock index 3ad904d4..0cca9656 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "eb45986c69ebabc1023ec6f15a4bc05c", + "content-hash": "1ba8da9f3e36ff3ace1bee4b1b66eb4a", "packages": [ { "name": "ergebnis/json", From b0aabcfb222566eaf87cc96487e5827e1114a457 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 5 Jan 2023 21:07:38 +0100 Subject: [PATCH 2/3] Enhancement: Suggest composer/semver --- composer.json | 3 +++ composer.lock | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3667bb63..97e23113 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,9 @@ "symfony/finder": "^5.0.0 || ^6.0.0", "vimeo/psalm": "^5.4.0" }, + "suggest": { + "composer/semver": "If you want to use ComposerJsonNormalizer or VersionConstraintNormalizer" + }, "autoload": { "psr-4": { "Ergebnis\\Json\\Normalizer\\": "src/" diff --git a/composer.lock b/composer.lock index 0cca9656..d79f567e 100644 --- a/composer.lock +++ b/composer.lock @@ -6109,5 +6109,5 @@ "platform-overrides": { "php": "8.0.25" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } From 06611333f6332d4c203c05a26600c4f324dd822a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 5 Jan 2023 22:04:54 +0100 Subject: [PATCH 3/3] Enhancement: Skip normalization of unparseable version constraints --- CHANGELOG.md | 2 + composer-require-checker.json | 3 +- infection.json | 2 +- src/Exception/DependencyMissing.php | 37 ++++++++++++ .../Composer/ComposerJsonNormalizer.php | 13 ++++- .../Composer/VersionConstraintNormalizer.php | 23 ++++++-- .../No/Invalid/normalized.json | 12 ++-- .../No/Invalid/normalized.json | 12 ++-- .../No/Invalid/normalized.json | 12 ++-- .../No/Invalid/normalized.json | 12 ++-- .../No/Invalid/normalized.json | 12 ++-- .../No/Invalid/normalized.json | 12 ++-- test/Unit/Exception/DependencyMissingTest.php | 57 +++++++++++++++++++ 13 files changed, 166 insertions(+), 43 deletions(-) create mode 100644 src/Exception/DependencyMissing.php create mode 100644 test/Unit/Exception/DependencyMissingTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 848494a4..6b9f0857 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ For a full diff see [`3.0.0...main`][3.0.0...main]. - Adjusted `Vendor\Composer\BinNormalizer`, `Vendor\Composer\PackageHashNormalizer`, `Vendor\Composer\VersionConstraintNormalizer`, and `SchemaNormalizer` to encode JSON with `JSON_UNESCAPED_UNICODE` flag ([#802]), by [@localheinz] - Adjusted `Vendor\Composer\ComposerJsonNormalizer` to reject JSON when it is not an object ([#804]), by [@localheinz] - Adjusted `Vendor\Composer\ComposerJsonNormalizer` to compose `WithFinalNewLineNormalizer` ([#806]), by [@localheinz] +- Adjusted `Vendor\Composer\VersionConstraintNormalizer` to skip normalization of version constraints when they can not be parsed by `Composer\Semver\VersionParser` ([#813]), by [@fredden] and [@localheinz] ### Fixed @@ -557,6 +558,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0]. [#802]: https://github.com/ergebnis/json-normalizer/pull/802 [#804]: https://github.com/ergebnis/json-normalizer/pull/804 [#805]: https://github.com/ergebnis/json-normalizer/pull/805 +[#813]: https://github.com/ergebnis/json-normalizer/pull/813 [@BackEndTea]: https://github.com/BackEndTea [@dependabot]: https://github.com/dependabot diff --git a/composer-require-checker.json b/composer-require-checker.json index 67d0aa16..14d2426b 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -14,6 +14,7 @@ "static", "string", "true", - "void" + "void", + "Composer\\Semver\\VersionParser" ] } diff --git a/infection.json b/infection.json index 83f4f8b2..4ddae284 100644 --- a/infection.json +++ b/infection.json @@ -4,7 +4,7 @@ "text": ".build/infection/infection-log.txt" }, "minCoveredMsi": 90, - "minMsi": 86, + "minMsi": 85, "phpUnit": { "configDir": "test\/Unit" }, diff --git a/src/Exception/DependencyMissing.php b/src/Exception/DependencyMissing.php new file mode 100644 index 00000000..a1428152 --- /dev/null +++ b/src/Exception/DependencyMissing.php @@ -0,0 +1,37 @@ +normalizer = new Normalizer\ChainNormalizer( new Normalizer\SchemaNormalizer( $schemaUri, @@ -74,7 +85,7 @@ public function __construct(string $schemaUri) ), self::binNormalizer(), new PackageHashNormalizer(), - new VersionConstraintNormalizer(), + new VersionConstraintNormalizer(new Semver\VersionParser()), new Normalizer\WithFinalNewLineNormalizer(), ); } diff --git a/src/Vendor/Composer/VersionConstraintNormalizer.php b/src/Vendor/Composer/VersionConstraintNormalizer.php index 7f56df68..6d4ee99f 100644 --- a/src/Vendor/Composer/VersionConstraintNormalizer.php +++ b/src/Vendor/Composer/VersionConstraintNormalizer.php @@ -13,6 +13,7 @@ namespace Ergebnis\Json\Normalizer\Vendor\Composer; +use Composer\Semver; use Ergebnis\Json\Json; use Ergebnis\Json\Normalizer\Format; use Ergebnis\Json\Normalizer\Normalizer; @@ -41,6 +42,10 @@ final class VersionConstraintNormalizer implements Normalizer ], ]; + public function __construct(private Semver\VersionParser $versionParser) + { + } + public function normalize(Json $json): Json { $decoded = $json->decoded(); @@ -65,8 +70,8 @@ public function normalize(Json $json): Json continue; } - $decoded->{$name} = \array_map(static function (string $versionConstraint): string { - return self::normalizeVersionConstraint($versionConstraint); + $decoded->{$name} = \array_map(function (string $versionConstraint): string { + return $this->normalizeVersionConstraint($versionConstraint); }, $packages); } @@ -79,9 +84,19 @@ public function normalize(Json $json): Json return Json::fromString($encoded); } - private static function normalizeVersionConstraint(string $versionConstraint): string + private function normalizeVersionConstraint(string $versionConstraint): string { - $normalized = $versionConstraint; + $normalized = \trim(\str_replace( + ' ', + ' ', + $versionConstraint, + )); + + try { + $this->versionParser->parseConstraints($normalized); + } catch (\UnexpectedValueException) { + return $normalized; + } foreach (self::MAP as [$pattern, $glue]) { /** @var array $split */ diff --git a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Conflict/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Conflict/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json index 9a386a3e..41d8336e 100644 --- a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Conflict/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json +++ b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Conflict/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json @@ -7,10 +7,10 @@ "invalid/04-invalid-version-untrimmed": "1.0.0-meh", "invalid/05-operator-abuse-trimmed": ">2.0,,<=3.0", "invalid/06-operator-abuse-untrimmed": ">2.0,,<=3.0", - "invalid/07-operator-abuse-2-trimmed": ">2.0,,<=3.0", - "invalid/08-operator-abuse-2-untrimmed": ">2.0,,<=3.0", - "invalid/09-operator-abuse-3-trimmed": ">2.0 || || <=3.0", - "invalid/10-operator-abuse-3-untrimmed": ">2.0 || || <=3.0", + "invalid/07-operator-abuse-2-trimmed": ">2.0 ,, <=3.0", + "invalid/08-operator-abuse-2-untrimmed": ">2.0 ,, <=3.0", + "invalid/09-operator-abuse-3-trimmed": ">2.0 ||| <=3.0", + "invalid/10-operator-abuse-3-untrimmed": ">2.0 ||| <=3.0", "invalid/11-leading-operator-trimmed": ",^1@dev || ^4@dev", "invalid/12-leading-operator-untrimmed": ",^1@dev || ^4@dev", "invalid/13-leading-operator-2-trimmed": ",^1@dev", @@ -19,8 +19,8 @@ "invalid/16-leading-operator-3-untrimmed": "|| ^1@dev", "invalid/17-trailing-operator-trimmed": "^1@dev ||", "invalid/18-trailing-operator-untrimmed": "^1@dev ||", - "invalid/19-trailing-operator-2-trimmed": "^1@dev,", - "invalid/20-trailing-operator-2-untrimmed": "^1@dev,", + "invalid/19-trailing-operator-2-trimmed": "^1@dev ,", + "invalid/20-trailing-operator-2-untrimmed": "^1@dev ,", "invalid/21-caret-wildcard-w-o-dev-trimmed": "^2.0.*", "invalid/22-caret-wildcard-w-o-dev-untrimmed": "^2.0.*", "invalid/23-caret-wildcard-w-o-dev-2-trimmed": "^2.0.x", diff --git a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Provide/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Provide/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json index 1d4678c1..7dbdcad4 100644 --- a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Provide/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json +++ b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Provide/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json @@ -7,10 +7,10 @@ "invalid/04-invalid-version-untrimmed": "1.0.0-meh", "invalid/05-operator-abuse-trimmed": ">2.0,,<=3.0", "invalid/06-operator-abuse-untrimmed": ">2.0,,<=3.0", - "invalid/07-operator-abuse-2-trimmed": ">2.0,,<=3.0", - "invalid/08-operator-abuse-2-untrimmed": ">2.0,,<=3.0", - "invalid/09-operator-abuse-3-trimmed": ">2.0 || || <=3.0", - "invalid/10-operator-abuse-3-untrimmed": ">2.0 || || <=3.0", + "invalid/07-operator-abuse-2-trimmed": ">2.0 ,, <=3.0", + "invalid/08-operator-abuse-2-untrimmed": ">2.0 ,, <=3.0", + "invalid/09-operator-abuse-3-trimmed": ">2.0 ||| <=3.0", + "invalid/10-operator-abuse-3-untrimmed": ">2.0 ||| <=3.0", "invalid/11-leading-operator-trimmed": ",^1@dev || ^4@dev", "invalid/12-leading-operator-untrimmed": ",^1@dev || ^4@dev", "invalid/13-leading-operator-2-trimmed": ",^1@dev", @@ -19,8 +19,8 @@ "invalid/16-leading-operator-3-untrimmed": "|| ^1@dev", "invalid/17-trailing-operator-trimmed": "^1@dev ||", "invalid/18-trailing-operator-untrimmed": "^1@dev ||", - "invalid/19-trailing-operator-2-trimmed": "^1@dev,", - "invalid/20-trailing-operator-2-untrimmed": "^1@dev,", + "invalid/19-trailing-operator-2-trimmed": "^1@dev ,", + "invalid/20-trailing-operator-2-untrimmed": "^1@dev ,", "invalid/21-caret-wildcard-w-o-dev-trimmed": "^2.0.*", "invalid/22-caret-wildcard-w-o-dev-untrimmed": "^2.0.*", "invalid/23-caret-wildcard-w-o-dev-2-trimmed": "^2.0.x", diff --git a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Replace/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Replace/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json index 885df36d..dd86edf8 100644 --- a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Replace/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json +++ b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Replace/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json @@ -7,10 +7,10 @@ "invalid/04-invalid-version-untrimmed": "1.0.0-meh", "invalid/05-operator-abuse-trimmed": ">2.0,,<=3.0", "invalid/06-operator-abuse-untrimmed": ">2.0,,<=3.0", - "invalid/07-operator-abuse-2-trimmed": ">2.0,,<=3.0", - "invalid/08-operator-abuse-2-untrimmed": ">2.0,,<=3.0", - "invalid/09-operator-abuse-3-trimmed": ">2.0 || || <=3.0", - "invalid/10-operator-abuse-3-untrimmed": ">2.0 || || <=3.0", + "invalid/07-operator-abuse-2-trimmed": ">2.0 ,, <=3.0", + "invalid/08-operator-abuse-2-untrimmed": ">2.0 ,, <=3.0", + "invalid/09-operator-abuse-3-trimmed": ">2.0 ||| <=3.0", + "invalid/10-operator-abuse-3-untrimmed": ">2.0 ||| <=3.0", "invalid/11-leading-operator-trimmed": ",^1@dev || ^4@dev", "invalid/12-leading-operator-untrimmed": ",^1@dev || ^4@dev", "invalid/13-leading-operator-2-trimmed": ",^1@dev", @@ -19,8 +19,8 @@ "invalid/16-leading-operator-3-untrimmed": "|| ^1@dev", "invalid/17-trailing-operator-trimmed": "^1@dev ||", "invalid/18-trailing-operator-untrimmed": "^1@dev ||", - "invalid/19-trailing-operator-2-trimmed": "^1@dev,", - "invalid/20-trailing-operator-2-untrimmed": "^1@dev,", + "invalid/19-trailing-operator-2-trimmed": "^1@dev ,", + "invalid/20-trailing-operator-2-untrimmed": "^1@dev ,", "invalid/21-caret-wildcard-w-o-dev-trimmed": "^2.0.*", "invalid/22-caret-wildcard-w-o-dev-untrimmed": "^2.0.*", "invalid/23-caret-wildcard-w-o-dev-2-trimmed": "^2.0.x", diff --git a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Require/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Require/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json index ca6c602d..acdb40d7 100644 --- a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Require/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json +++ b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/Require/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json @@ -7,10 +7,10 @@ "invalid/04-invalid-version-untrimmed": "1.0.0-meh", "invalid/05-operator-abuse-trimmed": ">2.0,,<=3.0", "invalid/06-operator-abuse-untrimmed": ">2.0,,<=3.0", - "invalid/07-operator-abuse-2-trimmed": ">2.0,,<=3.0", - "invalid/08-operator-abuse-2-untrimmed": ">2.0,,<=3.0", - "invalid/09-operator-abuse-3-trimmed": ">2.0 || || <=3.0", - "invalid/10-operator-abuse-3-untrimmed": ">2.0 || || <=3.0", + "invalid/07-operator-abuse-2-trimmed": ">2.0 ,, <=3.0", + "invalid/08-operator-abuse-2-untrimmed": ">2.0 ,, <=3.0", + "invalid/09-operator-abuse-3-trimmed": ">2.0 ||| <=3.0", + "invalid/10-operator-abuse-3-untrimmed": ">2.0 ||| <=3.0", "invalid/11-leading-operator-trimmed": ",^1@dev || ^4@dev", "invalid/12-leading-operator-untrimmed": ",^1@dev || ^4@dev", "invalid/13-leading-operator-2-trimmed": ",^1@dev", @@ -19,8 +19,8 @@ "invalid/16-leading-operator-3-untrimmed": "|| ^1@dev", "invalid/17-trailing-operator-trimmed": "^1@dev ||", "invalid/18-trailing-operator-untrimmed": "^1@dev ||", - "invalid/19-trailing-operator-2-trimmed": "^1@dev,", - "invalid/20-trailing-operator-2-untrimmed": "^1@dev,", + "invalid/19-trailing-operator-2-trimmed": "^1@dev ,", + "invalid/20-trailing-operator-2-untrimmed": "^1@dev ,", "invalid/21-caret-wildcard-w-o-dev-trimmed": "^2.0.*", "invalid/22-caret-wildcard-w-o-dev-untrimmed": "^2.0.*", "invalid/23-caret-wildcard-w-o-dev-2-trimmed": "^2.0.x", diff --git a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/RequireDev/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/RequireDev/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json index 36ea39a8..a7ca7b2d 100644 --- a/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/RequireDev/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json +++ b/test/Fixture/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/RequireDev/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json @@ -7,10 +7,10 @@ "invalid/04-invalid-version-untrimmed": "1.0.0-meh", "invalid/05-operator-abuse-trimmed": ">2.0,,<=3.0", "invalid/06-operator-abuse-untrimmed": ">2.0,,<=3.0", - "invalid/07-operator-abuse-2-trimmed": ">2.0,,<=3.0", - "invalid/08-operator-abuse-2-untrimmed": ">2.0,,<=3.0", - "invalid/09-operator-abuse-3-trimmed": ">2.0 || || <=3.0", - "invalid/10-operator-abuse-3-untrimmed": ">2.0 || || <=3.0", + "invalid/07-operator-abuse-2-trimmed": ">2.0 ,, <=3.0", + "invalid/08-operator-abuse-2-untrimmed": ">2.0 ,, <=3.0", + "invalid/09-operator-abuse-3-trimmed": ">2.0 ||| <=3.0", + "invalid/10-operator-abuse-3-untrimmed": ">2.0 ||| <=3.0", "invalid/11-leading-operator-trimmed": ",^1@dev || ^4@dev", "invalid/12-leading-operator-untrimmed": ",^1@dev || ^4@dev", "invalid/13-leading-operator-2-trimmed": ",^1@dev", @@ -19,8 +19,8 @@ "invalid/16-leading-operator-3-untrimmed": "|| ^1@dev", "invalid/17-trailing-operator-trimmed": "^1@dev ||", "invalid/18-trailing-operator-untrimmed": "^1@dev ||", - "invalid/19-trailing-operator-2-trimmed": "^1@dev,", - "invalid/20-trailing-operator-2-untrimmed": "^1@dev,", + "invalid/19-trailing-operator-2-trimmed": "^1@dev ,", + "invalid/20-trailing-operator-2-untrimmed": "^1@dev ,", "invalid/21-caret-wildcard-w-o-dev-trimmed": "^2.0.*", "invalid/22-caret-wildcard-w-o-dev-untrimmed": "^2.0.*", "invalid/23-caret-wildcard-w-o-dev-2-trimmed": "^2.0.x", diff --git a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json index 3c0db912..ee364227 100644 --- a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json +++ b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/Invalid/normalized.json @@ -7,10 +7,10 @@ "invalid/04-invalid-version-untrimmed": "1.0.0-meh", "invalid/05-operator-abuse-trimmed": ">2.0,,<=3.0", "invalid/06-operator-abuse-untrimmed": ">2.0,,<=3.0", - "invalid/07-operator-abuse-2-trimmed": ">2.0,,<=3.0", - "invalid/08-operator-abuse-2-untrimmed": ">2.0,,<=3.0", - "invalid/09-operator-abuse-3-trimmed": ">2.0 || || <=3.0", - "invalid/10-operator-abuse-3-untrimmed": ">2.0 || || <=3.0", + "invalid/07-operator-abuse-2-trimmed": ">2.0 ,, <=3.0", + "invalid/08-operator-abuse-2-untrimmed": ">2.0 ,, <=3.0", + "invalid/09-operator-abuse-3-trimmed": ">2.0 ||| <=3.0", + "invalid/10-operator-abuse-3-untrimmed": ">2.0 ||| <=3.0", "invalid/11-leading-operator-trimmed": ",^1@dev || ^4@dev", "invalid/12-leading-operator-untrimmed": ",^1@dev || ^4@dev", "invalid/13-leading-operator-2-trimmed": ",^1@dev", @@ -19,8 +19,8 @@ "invalid/16-leading-operator-3-untrimmed": "|| ^1@dev", "invalid/17-trailing-operator-trimmed": "^1@dev ||", "invalid/18-trailing-operator-untrimmed": "^1@dev ||", - "invalid/19-trailing-operator-2-trimmed": "^1@dev,", - "invalid/20-trailing-operator-2-untrimmed": "^1@dev,", + "invalid/19-trailing-operator-2-trimmed": "^1@dev ,", + "invalid/20-trailing-operator-2-untrimmed": "^1@dev ,", "invalid/21-caret-wildcard-w-o-dev-trimmed": "^2.0.*", "invalid/22-caret-wildcard-w-o-dev-untrimmed": "^2.0.*", "invalid/23-caret-wildcard-w-o-dev-2-trimmed": "^2.0.x", diff --git a/test/Unit/Exception/DependencyMissingTest.php b/test/Unit/Exception/DependencyMissingTest.php new file mode 100644 index 00000000..50827f9b --- /dev/null +++ b/test/Unit/Exception/DependencyMissingTest.php @@ -0,0 +1,57 @@ +slug(), + $faker->slug(), + ); + + $exception = Exception\DependencyMissing::for( + $className, + $packageName, + ); + + $message = \sprintf( + <<<'TXT' +To use "%s", the package "%s" is required. + +Run + +composer require "%s" + +to install it. +TXT, + $className, + $packageName, + $packageName, + ); + + self::assertSame($message, $exception->getMessage()); + } +}