mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Fix CS (#11003)
This commit is contained in:
parent
6e205a0c84
commit
131da999ac
357 changed files with 5943 additions and 9174 deletions
|
@ -22,10 +22,10 @@ class PackageSorterTest extends TestCase
|
|||
{
|
||||
public function testSortingDoesNothingWithNoDependencies(): void
|
||||
{
|
||||
$packages[] = $this->createPackage('foo/bar1', array());
|
||||
$packages[] = $this->createPackage('foo/bar2', array());
|
||||
$packages[] = $this->createPackage('foo/bar3', array());
|
||||
$packages[] = $this->createPackage('foo/bar4', array());
|
||||
$packages[] = $this->createPackage('foo/bar1', []);
|
||||
$packages[] = $this->createPackage('foo/bar2', []);
|
||||
$packages[] = $this->createPackage('foo/bar3', []);
|
||||
$packages[] = $this->createPackage('foo/bar4', []);
|
||||
|
||||
$sortedPackages = PackageSorter::sortPackages($packages);
|
||||
|
||||
|
@ -34,117 +34,117 @@ class PackageSorterTest extends TestCase
|
|||
|
||||
public function sortingOrdersDependenciesHigherThanPackageDataProvider(): array
|
||||
{
|
||||
return array(
|
||||
'one package is dep' => array(
|
||||
array(
|
||||
$this->createPackage('foo/bar1', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar2', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar3', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar4', array()),
|
||||
),
|
||||
array(
|
||||
return [
|
||||
'one package is dep' => [
|
||||
[
|
||||
$this->createPackage('foo/bar1', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar2', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar3', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar4', []),
|
||||
],
|
||||
[
|
||||
'foo/bar4',
|
||||
'foo/bar1',
|
||||
'foo/bar2',
|
||||
'foo/bar3',
|
||||
),
|
||||
),
|
||||
'one package has more deps' => array(
|
||||
array(
|
||||
$this->createPackage('foo/bar1', array('foo/bar2')),
|
||||
$this->createPackage('foo/bar2', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar3', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar4', array()),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
'one package has more deps' => [
|
||||
[
|
||||
$this->createPackage('foo/bar1', ['foo/bar2']),
|
||||
$this->createPackage('foo/bar2', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar3', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar4', []),
|
||||
],
|
||||
[
|
||||
'foo/bar4',
|
||||
'foo/bar2',
|
||||
'foo/bar1',
|
||||
'foo/bar3',
|
||||
),
|
||||
),
|
||||
'package is required by many, but requires one other' => array(
|
||||
array(
|
||||
$this->createPackage('foo/bar1', array('foo/bar3')),
|
||||
$this->createPackage('foo/bar2', array('foo/bar3')),
|
||||
$this->createPackage('foo/bar3', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar4', array()),
|
||||
$this->createPackage('foo/bar5', array('foo/bar3')),
|
||||
$this->createPackage('foo/bar6', array('foo/bar3')),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
'package is required by many, but requires one other' => [
|
||||
[
|
||||
$this->createPackage('foo/bar1', ['foo/bar3']),
|
||||
$this->createPackage('foo/bar2', ['foo/bar3']),
|
||||
$this->createPackage('foo/bar3', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar4', []),
|
||||
$this->createPackage('foo/bar5', ['foo/bar3']),
|
||||
$this->createPackage('foo/bar6', ['foo/bar3']),
|
||||
],
|
||||
[
|
||||
'foo/bar4',
|
||||
'foo/bar3',
|
||||
'foo/bar1',
|
||||
'foo/bar2',
|
||||
'foo/bar5',
|
||||
'foo/bar6',
|
||||
),
|
||||
),
|
||||
'one package has many requires' => array(
|
||||
array(
|
||||
$this->createPackage('foo/bar1', array('foo/bar2')),
|
||||
$this->createPackage('foo/bar2', array()),
|
||||
$this->createPackage('foo/bar3', array('foo/bar4')),
|
||||
$this->createPackage('foo/bar4', array()),
|
||||
$this->createPackage('foo/bar5', array('foo/bar2')),
|
||||
$this->createPackage('foo/bar6', array('foo/bar2')),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
'one package has many requires' => [
|
||||
[
|
||||
$this->createPackage('foo/bar1', ['foo/bar2']),
|
||||
$this->createPackage('foo/bar2', []),
|
||||
$this->createPackage('foo/bar3', ['foo/bar4']),
|
||||
$this->createPackage('foo/bar4', []),
|
||||
$this->createPackage('foo/bar5', ['foo/bar2']),
|
||||
$this->createPackage('foo/bar6', ['foo/bar2']),
|
||||
],
|
||||
[
|
||||
'foo/bar2',
|
||||
'foo/bar4',
|
||||
'foo/bar1',
|
||||
'foo/bar3',
|
||||
'foo/bar5',
|
||||
'foo/bar6',
|
||||
),
|
||||
),
|
||||
'circular deps sorted alphabetically if weighted equally' => array(
|
||||
array(
|
||||
$this->createPackage('foo/bar1', array('circular/part1')),
|
||||
$this->createPackage('foo/bar2', array('circular/part2')),
|
||||
$this->createPackage('circular/part1', array('circular/part2')),
|
||||
$this->createPackage('circular/part2', array('circular/part1')),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
'circular deps sorted alphabetically if weighted equally' => [
|
||||
[
|
||||
$this->createPackage('foo/bar1', ['circular/part1']),
|
||||
$this->createPackage('foo/bar2', ['circular/part2']),
|
||||
$this->createPackage('circular/part1', ['circular/part2']),
|
||||
$this->createPackage('circular/part2', ['circular/part1']),
|
||||
],
|
||||
[
|
||||
'circular/part1',
|
||||
'circular/part2',
|
||||
'foo/bar1',
|
||||
'foo/bar2',
|
||||
),
|
||||
),
|
||||
'equal weight sorted alphabetically' => array(
|
||||
array(
|
||||
$this->createPackage('foo/bar10', array('foo/dep')),
|
||||
$this->createPackage('foo/bar2', array('foo/dep')),
|
||||
$this->createPackage('foo/baz', array('foo/dep')),
|
||||
$this->createPackage('foo/dep', array()),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
'equal weight sorted alphabetically' => [
|
||||
[
|
||||
$this->createPackage('foo/bar10', ['foo/dep']),
|
||||
$this->createPackage('foo/bar2', ['foo/dep']),
|
||||
$this->createPackage('foo/baz', ['foo/dep']),
|
||||
$this->createPackage('foo/dep', []),
|
||||
],
|
||||
[
|
||||
'foo/dep',
|
||||
'foo/bar2',
|
||||
'foo/bar10',
|
||||
'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(
|
||||
],
|
||||
],
|
||||
'pre-weighted packages bumped to top incl their deps' => [
|
||||
[
|
||||
$this->createPackage('foo/bar', ['foo/dep']),
|
||||
$this->createPackage('foo/bar2', ['foo/dep2']),
|
||||
$this->createPackage('foo/dep', []),
|
||||
$this->createPackage('foo/dep2', []),
|
||||
],
|
||||
[
|
||||
'foo/dep',
|
||||
'foo/bar',
|
||||
'foo/dep2',
|
||||
'foo/bar2',
|
||||
),
|
||||
array(
|
||||
'foo/bar' => -1000
|
||||
)
|
||||
),
|
||||
);
|
||||
],
|
||||
[
|
||||
'foo/bar' => -1000,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ class PackageSorterTest extends TestCase
|
|||
public function testSortingOrdersDependenciesHigherThanPackage(array $packages, array $expectedOrderedList, array $weights = []): void
|
||||
{
|
||||
$sortedPackages = PackageSorter::sortPackages($packages, $weights);
|
||||
$sortedPackageNames = array_map(function ($package): string {
|
||||
$sortedPackageNames = array_map(static function ($package): string {
|
||||
return $package->getName();
|
||||
}, $sortedPackages);
|
||||
|
||||
|
@ -165,16 +165,13 @@ class PackageSorterTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string[] $requires
|
||||
*
|
||||
* @return Package
|
||||
*/
|
||||
private function createPackage(string $name, array $requires): Package
|
||||
{
|
||||
$package = new Package($name, '1.0.0.0', '1.0.0');
|
||||
|
||||
$links = array();
|
||||
$links = [];
|
||||
foreach ($requires as $requireName) {
|
||||
$links[$requireName] = new Link($package->getName(), $requireName, new MatchAllConstraint);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue