Skip to content

Commit f7a24c9

Browse files
committed
Merge branch '1.x' into 2.x
* 1.x: Flex recipe should always be installed first
2 parents cc6f511 + e7f3f34 commit f7a24c9

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

src/Flex.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,10 @@ public function fetchRecipes(array $operations, bool $reset): array
484484
$data = $this->downloader->getRecipes($operations);
485485
$manifests = $data['manifests'] ?? [];
486486
$locks = $data['locks'] ?? [];
487-
// symfony/flex and symfony/framework-bundle recipes should always be applied first
487+
// symfony/flex recipes should always be applied first
488+
$flexRecipe = [];
489+
// symfony/framework-bundle recipe should always be applied first after the metapackages
488490
$recipes = [
489-
'symfony/flex' => null,
490491
'symfony/framework-bundle' => null,
491492
];
492493
$metaRecipes = [];
@@ -530,6 +531,8 @@ public function fetchRecipes(array $operations, bool $reset): array
530531
if (isset($manifests[$name])) {
531532
if ('metapackage' === $package->getType()) {
532533
$metaRecipes[$name] = new Recipe($package, $name, $job, $manifests[$name], $locks[$name] ?? []);
534+
} elseif ('symfony/flex' === $name) {
535+
$flexRecipe = [$name => new Recipe($package, $name, $job, $manifests[$name], $locks[$name] ?? [])];
533536
} else {
534537
$recipes[$name] = new Recipe($package, $name, $job, $manifests[$name], $locks[$name] ?? []);
535538
}
@@ -557,7 +560,7 @@ public function fetchRecipes(array $operations, bool $reset): array
557560
}
558561
}
559562

560-
return array_merge($metaRecipes, array_filter($recipes));
563+
return array_merge($flexRecipe, $metaRecipes, array_filter($recipes));
561564
}
562565

563566
public function truncatePackages(PrePoolCreateEvent $event)

tests/FlexTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,41 @@ public function getPackagesForAutoDiscovery(): array
178178
return $return;
179179
}
180180

181+
public function testFetchRecipesOrder()
182+
{
183+
$packages = [
184+
['name' => 'symfony/console', 'type' => 'library'],
185+
['name' => 'symfony/flex', 'type' => 'composer-plugin'],
186+
['name' => 'symfony/framework-bundle', 'type' => 'library'],
187+
['name' => 'symfony/webapp-meta', 'type' => 'metapackage'],
188+
];
189+
190+
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE);
191+
$rootPackage = $this->mockRootPackage(['symfony' => ['allow-contrib' => true]]);
192+
193+
$flex = $this->mockFlex($io, $rootPackage, null, [
194+
'manifests' => array_reduce($packages, static function (array $manifests, array $packageInfo) {
195+
$manifests[$packageInfo['name']] = ['manifest' => []];
196+
197+
return $manifests;
198+
}, []),
199+
]);
200+
201+
$recipes = $flex->fetchRecipes(array_map(static function (array $packageInfo) {
202+
$package = new Package($packageInfo['name'], '1.0.0', '1.0.0');
203+
$package->setType($packageInfo['type']);
204+
205+
return new InstallOperation($package);
206+
}, $packages), true);
207+
208+
$this->assertSame([
209+
'symfony/flex',
210+
'symfony/webapp-meta',
211+
'symfony/framework-bundle',
212+
'symfony/console',
213+
], array_keys($recipes));
214+
}
215+
181216
public static function getTestPackages(): array
182217
{
183218
return [

0 commit comments

Comments
 (0)