/**
  * Orders all packages by comparing their dependencies. By this, the packages
  * and package configurations arrays holds all packages in the correct
  * initialization order.
  *
  * @param array $packageStates The unordered package states
  * @return array ordered package states.
  */
 protected function sortAvailablePackagesByDependencies(array $packageStates)
 {
     $packageOrderResolver = new PackageOrderResolver($packageStates['packages'], $this->collectPackageManifestData($packageStates));
     $packageStates['packages'] = $packageOrderResolver->sort();
     return $packageStates;
 }
 /**
  * @test
  * @dataProvider packagesAndDependenciesOrder
  * @param array $packages
  * @param array $expectedPackageOrder
  */
 public function availablePackagesAreSortedAfterTheirDependencies($packages, $expectedPackageOrder)
 {
     $orderResolver = new PackageOrderResolver($packages, $packages);
     $sortedPackages = $orderResolver->sort();
     $this->assertEquals($expectedPackageOrder, array_keys($sortedPackages), 'The packages have not been ordered according to their require!');
 }