From 8e709cf562d48691ce5e6726facd735e9c3e815c Mon Sep 17 00:00:00 2001 From: Reedy Date: Wed, 24 Nov 2021 12:38:26 +0000 Subject: [PATCH] Add failing test for https://github.com/wikimedia/composer-merge-plugin/issues/222 --- tests/phpunit/MergePluginTest.php | 21 +++++++++++++++++++ .../testGitHubIssue222/composer-extra.json | 5 +++++ .../fixtures/testGitHubIssue222/composer.json | 16 ++++++++++++++ .../testGitHubIssue222/composer.local.json | 9 ++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/phpunit/fixtures/testGitHubIssue222/composer-extra.json create mode 100644 tests/phpunit/fixtures/testGitHubIssue222/composer.json create mode 100644 tests/phpunit/fixtures/testGitHubIssue222/composer.local.json diff --git a/tests/phpunit/MergePluginTest.php b/tests/phpunit/MergePluginTest.php index 9b6356e..dcf5ba8 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" + ] + } + } +}