From 6b4c7c23bd39a745f98e1238b00fa44e80ee35fb Mon Sep 17 00:00:00 2001 From: "Andrey F. Mindubaev" Date: Tue, 5 Dec 2017 17:51:41 +0300 Subject: [PATCH] Apply recipe for symfony/framework-bundle first --- src/Flex.php | 6 +++++- tests/FlexTest.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/Flex.php b/src/Flex.php index 0cbe67ad0..f7a9f2c09 100644 --- a/src/Flex.php +++ b/src/Flex.php @@ -118,7 +118,11 @@ public function record(PackageEvent $event) { $operation = $event->getOperation(); if ($this->shouldRecordOperation($operation)) { - $this->operations[] = $operation; + if ($operation instanceof InstallOperation && 'symfony/framework-bundle' === $operation->getPackage()->getName()) { + array_unshift($this->operations, $operation); + } else { + $this->operations[] = $operation; + } } } diff --git a/tests/FlexTest.php b/tests/FlexTest.php index 444ea674f..f90d0eb76 100644 --- a/tests/FlexTest.php +++ b/tests/FlexTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Flex\Tests\Configurator; +namespace Symfony\Flex\Tests; use Composer\Composer; use Composer\Config; @@ -32,6 +32,33 @@ class FlexTest extends TestCase { + public function testFrameworkBundleRecord() + { + $lock = $this->getMockBuilder(Lock::class)->disableOriginalConstructor()->getMock(); + $lock->expects($this->any())->method('has')->will($this->returnValue(false)); + + $flex = \Closure::bind(function () use ($lock) { + $flex = new Flex(); + $flex->lock = $lock; + + return $flex; + }, null, Flex::class)->__invoke(); + /** @var InstallOperation[] $list */ + $list = [ + $operationFlex = new InstallOperation(new Package('symfony/flex', '1.0.0', '1.0.0')), + $operationFB = new InstallOperation(new Package('symfony/framework-bundle', '1.0.0', '1.0.0')), + $operationFoo = new InstallOperation(new Package('vendor/foo', '1.0.0', '1.0.0')), + ]; + foreach ($list as $operation) { + $event = $this->getMockBuilder(PackageEvent::class)->disableOriginalConstructor()->getMock(); + $event->expects($this->once())->method('getOperation')->willReturn($operation); + + $flex->record($event); + } + + $this->assertAttributeEquals([$operationFB, $operationFlex, $operationFoo], 'operations', $flex); + } + public function testPostInstall() { $package = new Package('dummy/dummy', '1.0.0', '1.0.0');