1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Merge branch '2.2' into main

This commit is contained in:
Jordi Boggiano 2022-03-15 22:20:21 +01:00
commit aad2f86edf
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
5 changed files with 50 additions and 6 deletions

View file

@ -127,6 +127,23 @@ class PackageSorterTest extends TestCase
'foo/baz',
),
),
'pre-weighted packages bumped to top incl their deps' => array(
array(
$this->createPackage('foo/bar', array('foo/dep')),
$this->createPackage('foo/bar2', array('foo/dep2')),
$this->createPackage('foo/dep', array()),
$this->createPackage('foo/dep2', array()),
),
array(
'foo/dep',
'foo/bar',
'foo/dep2',
'foo/bar2',
),
array(
'foo/bar' => -1000
)
),
);
}
@ -135,10 +152,11 @@ class PackageSorterTest extends TestCase
*
* @param Package[] $packages
* @param string[] $expectedOrderedList
* @param array<string, int> $weights
*/
public function testSortingOrdersDependenciesHigherThanPackage(array $packages, array $expectedOrderedList): void
public function testSortingOrdersDependenciesHigherThanPackage(array $packages, array $expectedOrderedList, array $weights = []): void
{
$sortedPackages = PackageSorter::sortPackages($packages);
$sortedPackages = PackageSorter::sortPackages($packages, $weights);
$sortedPackageNames = array_map(function ($package): string {
return $package->getName();
}, $sortedPackages);