Skip to content

Commit

Permalink
Enhancement: Assert that preferred-install is not sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 30, 2020
1 parent f318c64 commit 45083e0
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/Unit/Vendor/Composer/ConfigHashNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,49 @@ public function testNormalizeSortsConfigHashRecursivelyIfPropertyExists(string $
self::assertJsonStringEqualsJsonStringNormalized($expected->encoded(), $normalized->encoded());
}

/**
* @see https://github.com/ergebnis/composer-normalize/issues/644
* @see https://getcomposer.org/doc/06-config.md#preferred-install
*/
public function testNormalizeDoesNotSortPreferredInstall(): void
{
$json = Json::fromEncoded(
<<<'JSON'
{
"config": {
"sort-packages": true,
"preferred-install": {
"foo/*": "source",
"bar/*": "source",
"*": "dist"
}
}
}
JSON
);

$expected = Json::fromEncoded(
<<<'JSON'
{
"config": {
"preferred-install": {
"foo/*": "source",
"bar/*": "source",
"*": "dist"
},
"sort-packages": true
}
}
JSON
);

$normalizer = new ConfigHashNormalizer();

$normalized = $normalizer->normalize($json);

self::assertJsonStringEqualsJsonStringNormalized($expected->encoded(), $normalized->encoded());
}

/**
* @return \Generator<array<string>>
*/
Expand Down

0 comments on commit 45083e0

Please sign in to comment.