diff --git a/tests/phpunit/MergePluginTest.php b/tests/phpunit/MergePluginTest.php index 3c7d420..1c5269b 100644 --- a/tests/phpunit/MergePluginTest.php +++ b/tests/phpunit/MergePluginTest.php @@ -1572,6 +1572,27 @@ function ($args, $root) { $this->triggerPlugin($root->reveal(), $dir, $fireInit); } + public function testGitHubIssue222() + { + $that = $this; + $dir = $this->fixtureDir(__FUNCTION__); + + $root = $this->rootFromJson("{$dir}/composer.json"); + $root->setRequires(Argument::type('array'))->will( + function ($args) use ($that) { + $requires = $args[0]; + $that->assertCount(2, $requires); + $that->assertArrayHasKey('symfony/yaml', $requires); + + $that->assertEquals( + '5.3.6', + $requires['symfony/yaml']->getPrettyConstraint() + ); + } + ); + $this->triggerPlugin($root->reveal(), $dir); + } + /** * Generic provider for tests that should be tried with and without an * INIT event. diff --git a/tests/phpunit/fixtures/testGitHubIssue222/composer-extra.json b/tests/phpunit/fixtures/testGitHubIssue222/composer-extra.json new file mode 100644 index 0000000..1808cf5 --- /dev/null +++ b/tests/phpunit/fixtures/testGitHubIssue222/composer-extra.json @@ -0,0 +1,5 @@ +{ + "require": { + "symfony/yaml": "5.3.6" + } +} diff --git a/tests/phpunit/fixtures/testGitHubIssue222/composer.json b/tests/phpunit/fixtures/testGitHubIssue222/composer.json new file mode 100644 index 0000000..8803578 --- /dev/null +++ b/tests/phpunit/fixtures/testGitHubIssue222/composer.json @@ -0,0 +1,16 @@ +{ + "require": { + "wikimedia/composer-merge-plugin": "dev-master" + }, + "require-dev": { + "symfony/yaml": "~3.4|~5.1" + }, + "extra": { + "merge-plugin": { + "include": [ + "composer.local.json" + ], + "merge-dev": false + } + } +} diff --git a/tests/phpunit/fixtures/testGitHubIssue222/composer.local.json b/tests/phpunit/fixtures/testGitHubIssue222/composer.local.json new file mode 100644 index 0000000..572f83c --- /dev/null +++ b/tests/phpunit/fixtures/testGitHubIssue222/composer.local.json @@ -0,0 +1,9 @@ +{ + "extra": { + "merge-plugin": { + "include": [ + "composer-extra.json" + ] + } + } +}