Skip to content

Commit

Permalink
bug symfony#230 Sort recipes on update before configuration (covex-nn)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------

Sort recipes on update before configuration

Recipe for `symfony/framework-bundle` must be applied after recipe for `symfony/flex` and before all other recipes on install/update.

See symfony#225

Commits
-------

6b4c7c2 Apply recipe for symfony/framework-bundle first
  • Loading branch information
fabpot committed Dec 6, 2017
2 parents 8917eb9 + 6b4c7c2 commit d511e9d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Flex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
29 changes: 28 additions & 1 deletion tests/FlexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand Down

0 comments on commit d511e9d

Please sign in to comment.