Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/192046
Change subject: Upgrade composer-merge-plugin to 1.0.0 ...................................................................... Upgrade composer-merge-plugin to 1.0.0 Change-Id: I65bf1e0d0e972846ed9e30761738aaf3a2127c2f --- M composer.json M composer.lock M composer/ClassLoader.php M composer/installed.json D wikimedia/composer-merge-plugin/.gitignore D wikimedia/composer-merge-plugin/.scrutinizer.yml D wikimedia/composer-merge-plugin/.travis.yml M wikimedia/composer-merge-plugin/README.md D wikimedia/composer-merge-plugin/example/.gitignore D wikimedia/composer-merge-plugin/example/composer.json D wikimedia/composer-merge-plugin/example/composer.local.json D wikimedia/composer-merge-plugin/example/extensions/Foo/composer.json D wikimedia/composer-merge-plugin/phpunit.xml.dist M wikimedia/composer-merge-plugin/src/MergePlugin.php D wikimedia/composer-merge-plugin/tests/phpunit/MergePluginTest.php D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.local.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.local.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.local.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/extensions/Foo/composer.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.json D wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.local.json 24 files changed, 108 insertions(+), 668 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vendor refs/changes/46/192046/1 diff --git a/composer.json b/composer.json index 2a75c03..c4bdd20 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "ruflin/elastica": "1.3.0.0", "oojs/oojs-ui": "0.8.0", "wikimedia/cdb": "1.0.1", - "wikimedia/composer-merge-plugin": "0.5.0", + "wikimedia/composer-merge-plugin": "1.0.0", "zordius/lightncandy": "0.18" }, "prefer-stable": true, diff --git a/composer.lock b/composer.lock index a905c51..4a177b1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "065f42d5d65e22fae958a5759234888c", + "hash": "6188811094b69e07d37639aa9419dcf1", "packages": [ { "name": "cssjanus/cssjanus", @@ -327,16 +327,16 @@ }, { "name": "wikimedia/composer-merge-plugin", - "version": "v0.5.0", + "version": "v1.0.0", "source": { "type": "git", "url": "https://github.com/wikimedia/composer-merge-plugin.git", - "reference": "08ad40053b14d564dcd2a02239f67caa20d9ea75" + "reference": "ed426b785f9f786b33be4fd78584e43f4e962356" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/08ad40053b14d564dcd2a02239f67caa20d9ea75", - "reference": "08ad40053b14d564dcd2a02239f67caa20d9ea75", + "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/ed426b785f9f786b33be4fd78584e43f4e962356", + "reference": "ed426b785f9f786b33be4fd78584e43f4e962356", "shasum": "" }, "require": { @@ -364,7 +364,7 @@ "MIT" ], "description": "Composer plugin to merge multiple composer.json files", - "time": "2014-12-29 20:05:19" + "time": "2015-02-21 00:57:13" }, { "name": "zordius/lightncandy", @@ -419,7 +419,6 @@ "minimum-stability": "stable", "stability-flags": [], "prefer-stable": true, - "prefer-lowest": false, "platform": { "php": ">=5.3.3" }, diff --git a/composer/ClassLoader.php b/composer/ClassLoader.php index 5e1469e..70d78bc 100644 --- a/composer/ClassLoader.php +++ b/composer/ClassLoader.php @@ -54,8 +54,6 @@ private $useIncludePath = false; private $classMap = array(); - private $classMapAuthoritative = false; - public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -251,27 +249,6 @@ } /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not @@ -321,9 +298,6 @@ // class map lookup if (isset($this->classMap[$class])) { return $this->classMap[$class]; - } - if ($this->classMapAuthoritative) { - return false; } $file = $this->findFileWithExtension($class, '.php'); diff --git a/composer/installed.json b/composer/installed.json index 558d5d7..b3ac2a7 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -276,49 +276,6 @@ ] }, { - "name": "wikimedia/composer-merge-plugin", - "version": "v0.5.0", - "version_normalized": "0.5.0.0", - "source": { - "type": "git", - "url": "https://github.com/wikimedia/composer-merge-plugin.git", - "reference": "08ad40053b14d564dcd2a02239f67caa20d9ea75" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/08ad40053b14d564dcd2a02239f67caa20d9ea75", - "reference": "08ad40053b14d564dcd2a02239f67caa20d9ea75", - "shasum": "" - }, - "require": { - "composer-plugin-api": "1.0.0", - "php": ">=5.3.2" - }, - "require-dev": { - "composer/composer": "1.0.*@dev", - "jakub-onderka/php-parallel-lint": "~0.8", - "phpspec/prophecy-phpunit": "~1.0", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.1.0" - }, - "time": "2014-12-29 20:05:19", - "type": "composer-plugin", - "extra": { - "class": "Wikimedia\\Composer\\MergePlugin" - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Wikimedia\\Composer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Composer plugin to merge multiple composer.json files" - }, - { "name": "monolog/monolog", "version": "1.12.0", "version_normalized": "1.12.0.0", @@ -423,5 +380,48 @@ "MIT" ], "homepage": "https://www.mediawiki.org/wiki/OOjs_UI" + }, + { + "name": "wikimedia/composer-merge-plugin", + "version": "v1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/composer-merge-plugin.git", + "reference": "ed426b785f9f786b33be4fd78584e43f4e962356" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/ed426b785f9f786b33be4fd78584e43f4e962356", + "reference": "ed426b785f9f786b33be4fd78584e43f4e962356", + "shasum": "" + }, + "require": { + "composer-plugin-api": "1.0.0", + "php": ">=5.3.2" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "jakub-onderka/php-parallel-lint": "~0.8", + "phpspec/prophecy-phpunit": "~1.0", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.1.0" + }, + "time": "2015-02-21 00:57:13", + "type": "composer-plugin", + "extra": { + "class": "Wikimedia\\Composer\\MergePlugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Wikimedia\\Composer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin to merge multiple composer.json files" } ] diff --git a/wikimedia/composer-merge-plugin/.gitignore b/wikimedia/composer-merge-plugin/.gitignore deleted file mode 100644 index 6e09c41..0000000 --- a/wikimedia/composer-merge-plugin/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/.php-version -/composer.lock -/composer.phar -/phpunit.xml -/reports -/vendor diff --git a/wikimedia/composer-merge-plugin/.scrutinizer.yml b/wikimedia/composer-merge-plugin/.scrutinizer.yml deleted file mode 100644 index f851c82..0000000 --- a/wikimedia/composer-merge-plugin/.scrutinizer.yml +++ /dev/null @@ -1,58 +0,0 @@ -filter: - excluded_paths: - - 'tests/*' - -checks: - php: - php5_style_constructor: true - parameters_in_camelcaps: true - parameter_non_unique: true - parameter_doc_comments: true - param_doc_comment_if_not_inferrable: true - overriding_private_members: true - optional_parameters_at_the_end: true - one_class_per_file: true - non_commented_empty_catch_block: true - no_unnecessary_if: true - code_rating: true - duplication: true - variable_existence: true - useless_calls: true - use_statement_alias_conflict: true - unused_variables: true - unused_properties: true - unused_methods: true - unreachable_code: true - sql_injection_vulnerabilities: true - security_vulnerabilities: true - precedence_mistakes: true - precedence_in_conditions: true - no_property_on_interface: true - no_non_implemented_abstract_methods: true - deprecated_code_usage: true - closure_use_not_conflicting: true - closure_use_modifiable: true - avoid_useless_overridden_methods: true - avoid_conflicting_incrementers: true - assignment_of_null_return: true - avoid_corrupting_byteorder_marks: true - -tools: - external_code_coverage: - timeout: 300 - runs: 1 - php_analyzer: true - php_code_coverage: false - php_code_sniffer: - config: - standard: PSR2 - filter: - paths: ['src','tests'] - php_cpd: - enabled: true - excluded_dirs: ['vendor', 'tests', 'example'] - php_loc: - enabled: true - excluded_dirs: ['vendor', 'tests', 'example'] - php_pdepend: true - php_sim: true diff --git a/wikimedia/composer-merge-plugin/.travis.yml b/wikimedia/composer-merge-plugin/.travis.yml deleted file mode 100644 index 9ec8e7e..0000000 --- a/wikimedia/composer-merge-plugin/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php - -php: - - "5.3.3" - - "5.3" - - "5.4" - - "5.5" - - "5.6" - - "hhvm" - -sudo: false - -install: travis_retry composer install --no-interaction --prefer-source - -script: composer test - -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover reports/coverage.xml - -notifications: - irc: - channels: - - "chat.freenode.net#wikimedia-dev" - template: - - "%{repository}#%{build_number} (%{branch} - %{commit} %{author}): %{message} - %{build_url}" diff --git a/wikimedia/composer-merge-plugin/README.md b/wikimedia/composer-merge-plugin/README.md index 668cf78..53d6457 100644 --- a/wikimedia/composer-merge-plugin/README.md +++ b/wikimedia/composer-merge-plugin/README.md @@ -35,7 +35,10 @@ The `include` key can specify either a single value or an array of values. Each value is treated as a glob() pattern identifying additional composer.json style configuration files to merge into the configuration for the current -Composer execution. +Composer execution. By default the merge plugin is recursive, if an included +file also has a "merge-plugin" section it will also be processed. This +functionality can be disabled by setting `"recurse": false` inside the +"merge-plugin" section. The "require", "require-dev", "repositories" and "suggest" sections of the found configuration files will be merged into the root package configuration diff --git a/wikimedia/composer-merge-plugin/example/.gitignore b/wikimedia/composer-merge-plugin/example/.gitignore deleted file mode 100644 index ff72e2d..0000000 --- a/wikimedia/composer-merge-plugin/example/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/composer.lock -/vendor diff --git a/wikimedia/composer-merge-plugin/example/composer.json b/wikimedia/composer-merge-plugin/example/composer.json deleted file mode 100644 index 91c2175..0000000 --- a/wikimedia/composer-merge-plugin/example/composer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "repositories": [ - { - "type": "vcs", - "url": "./.." - } - ], - "require": { - "wikimedia/composer-merge-plugin": "*@dev" - }, - "config": { - "preferred-install": "source" - }, - "extra": { - "merge-plugin": { - "include": [ - "composer.local.json", - "extensions/*/composer.json" - ] - } - } -} diff --git a/wikimedia/composer-merge-plugin/example/composer.local.json b/wikimedia/composer-merge-plugin/example/composer.local.json deleted file mode 100644 index 4928c06..0000000 --- a/wikimedia/composer-merge-plugin/example/composer.local.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "monolog/monolog": "~1.0" - } -} diff --git a/wikimedia/composer-merge-plugin/example/extensions/Foo/composer.json b/wikimedia/composer-merge-plugin/example/extensions/Foo/composer.json deleted file mode 100644 index 7e36e3f..0000000 --- a/wikimedia/composer-merge-plugin/example/extensions/Foo/composer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "require": { - "wikimedia/cdb": "~1.0.0", - "monolog/monolog": "1.10.0" - } -} diff --git a/wikimedia/composer-merge-plugin/phpunit.xml.dist b/wikimedia/composer-merge-plugin/phpunit.xml.dist deleted file mode 100644 index b96cdab..0000000 --- a/wikimedia/composer-merge-plugin/phpunit.xml.dist +++ /dev/null @@ -1,12 +0,0 @@ -<phpunit colors="true" strict="true"> - <testsuites> - <testsuite name="Tests"> - <directory>./tests/phpunit</directory> - </testsuite> - </testsuites> - <filter> - <whitelist addUncoveredFilesFromWhitelist="true"> - <directory suffix=".php">./src</directory> - </whitelist> - </filter> -</phpunit> diff --git a/wikimedia/composer-merge-plugin/src/MergePlugin.php b/wikimedia/composer-merge-plugin/src/MergePlugin.php index 8555ebb..04c5588 100644 --- a/wikimedia/composer-merge-plugin/src/MergePlugin.php +++ b/wikimedia/composer-merge-plugin/src/MergePlugin.php @@ -13,14 +13,12 @@ use Composer\Composer; use Composer\Config; use Composer\EventDispatcher\EventSubscriberInterface; -use Composer\Factory; use Composer\Installer\InstallerEvent; use Composer\Installer\InstallerEvents; use Composer\IO\IOInterface; use Composer\Json\JsonFile; use Composer\Package\BasePackage; use Composer\Package\CompletePackage; -use Composer\Package\LinkConstraint\SpecificConstraint; use Composer\Package\Loader\ArrayLoader; use Composer\Package\RootPackageInterface; use Composer\Package\Version\VersionParser; @@ -92,6 +90,20 @@ protected $devMode; /** + * Whether to recursively include dependencies + * + * @var bool $recurse + */ + protected $recurse = true; + + /** + * Files that have already been processed + * + * @var string[] $loadedFiles + */ + protected $loadedFiles = array(); + + /** * {@inheritdoc} */ public function activate(Composer $composer, IOInterface $io) @@ -122,6 +134,9 @@ public function onInstallOrUpdate(CommandEvent $event) { $config = $this->readConfig($this->composer->getPackage()); + if (isset($config['recurse'])) { + $this->recurse = (bool)$config['recurse']; + } if ($config['include']) { $this->loader = new ArrayLoader(); $this->duplicateLinks = array( @@ -161,28 +176,49 @@ protected function mergePackages(array $config) { $root = $this->composer->getPackage(); - foreach (array_unique(array_reduce( + foreach (array_reduce( array_map('glob', $config['include']), 'array_merge', array() - )) as $path) { - $this->debug("Loading <comment>{$path}</comment>..."); - $json = $this->readPackageJson($path); - $package = $this->loader->load($json); + ) as $path) { + $this->loadFile($root, $path); + } + } - $this->mergeRequires($root, $package); - $this->mergeDevRequires($root, $package); + /** + * Read a JSON file and merge its contents + * + * @param RootPackageInterface $root + * @param string $path + */ + protected function loadFile($root, $path) + { + if (in_array($path, $this->loadedFiles)) { + $this->debug("Skipping duplicate <comment>$path</comment>..."); + return; + } else { + $this->loadedFiles[] = $path; + } + $this->debug("Loading <comment>{$path}</comment>..."); + $json = $this->readPackageJson($path); + $package = $this->loader->load($json); - if (isset($json['repositories'])) { - $this->addRepositories($json['repositories'], $root); - } + $this->mergeRequires($root, $package); + $this->mergeDevRequires($root, $package); - if ($package->getSuggests()) { - $root->setSuggests(array_merge( - $root->getSuggests(), - $package->getSuggests() - )); - } + if (isset($json['repositories'])) { + $this->addRepositories($json['repositories'], $root); + } + + if ($package->getSuggests()) { + $root->setSuggests(array_merge( + $root->getSuggests(), + $package->getSuggests() + )); + } + + if ($this->recurse && isset($json['extra']['merge-plugin'])) { + $this->mergePackages($json['extra']['merge-plugin']); } } diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/MergePluginTest.php b/wikimedia/composer-merge-plugin/tests/phpunit/MergePluginTest.php deleted file mode 100644 index d4271fd..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/MergePluginTest.php +++ /dev/null @@ -1,351 +0,0 @@ -<?php -/** - * This file is part of the Composer Merge plugin. - * - * Copyright (C) 2014 Bryan Davis, Wikimedia Foundation, and contributors - * - * This software may be modified and distributed under the terms of the MIT - * license. See the LICENSE file for details. - */ - -namespace Wikimedia\Composer; - -use Composer\Composer; -use Composer\Installer\InstallerEvent; -use Composer\Installer\InstallerEvents; -use Composer\IO\IOInterface; -use Composer\Package\BasePackage; -use Composer\Package\PackageInterface; -use Composer\Package\RootPackage; -use Composer\Script\CommandEvent; -use Composer\Script\ScriptEvents; -use Prophecy\Argument; - -/** - * @covers Wikimedia\Composer\MergePlugin - */ -class MergePluginTest extends \Prophecy\PhpUnit\ProphecyTestCase -{ - - /** - * @var Composer - */ - protected $composer; - - /** - * @var IOInterface - */ - protected $io; - - /** - * @var MergePlugin - */ - protected $fixture; - - protected function setUp() - { - parent::setUp(); - $this->composer = $this->prophesize('Composer\Composer'); - $this->io = $this->prophesize('Composer\IO\IOInterface'); - - $this->fixture = new MergePlugin(); - $this->fixture->activate( - $this->composer->reveal(), - $this->io->reveal() - ); - } - - public function testSubscribedEvents() - { - $subscriptions = MergePlugin::getSubscribedEvents(); - $this->assertEquals(3, count($subscriptions)); - $this->assertArrayHasKey( - InstallerEvents::PRE_DEPENDENCIES_SOLVING, - $subscriptions - ); - $this->assertArrayHasKey(ScriptEvents::PRE_INSTALL_CMD, $subscriptions); - $this->assertArrayHasKey(ScriptEvents::PRE_UPDATE_CMD, $subscriptions); - } - - /** - * Given a root package with no requires - * and a composer.local.json with one require - * When the plugin is run - * Then the root package should inherit the require - * and no modifications should be made by the pre-dependency hook. - */ - public function testOneMergeNoConflicts() - { - $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->assertEquals(1, count($requires)); - $that->assertArrayHasKey('monolog/monolog', $requires); - } - ); - - $root->getDevRequires()->shouldNotBeCalled(); - $root->getRepositories()->shouldNotBeCalled(); - $root->getSuggests()->shouldNotBeCalled(); - - $extraInstalls = $this->triggerPlugin($root->reveal(), $dir); - - $this->assertEquals(0, count($extraInstalls)); - } - - /** - * Given a root package with requires - * and a composer.local.json with requires - * and the same package is listed in multiple files - * When the plugin is run - * Then the root package should inherit the non-conflicting requires - * and extra installs should be proposed by the pre-dependency hook. - */ - public function testOneMergeWithConflicts() - { - $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->assertEquals(2, count($requires)); - $that->assertArrayHasKey( - 'wikimedia/composer-merge-plugin', - $requires - ); - $that->assertArrayHasKey('monolog/monolog', $requires); - } - ); - - $root->getDevRequires()->shouldBeCalled(); - $root->setDevRequires(Argument::type('array'))->will( - function ($args) use ($that) { - $requires = $args[0]; - $that->assertEquals(2, count($requires)); - $that->assertArrayHasKey('foo', $requires); - $that->assertArrayHasKey('xyzzy', $requires); - } - ); - - $root->getRepositories()->shouldNotBeCalled(); - $root->getSuggests()->shouldNotBeCalled(); - - $extraInstalls = $this->triggerPlugin($root->reveal(), $dir); - - $this->assertEquals(1, count($extraInstalls)); - $this->assertEquals('monolog/monolog', $extraInstalls[0][0]); - } - - /** - * Given a root package - * and a composer.local.json with a repository - * When the plugin is run - * Then the root package should inherit the repository - */ - public function testMergedRepositories() - { - $that = $this; - $io = $this->io; - $dir = $this->fixtureDir(__FUNCTION__); - - $repoManager = $this->prophesize( - 'Composer\Repository\RepositoryManager' - ); - $repoManager->createRepository( - Argument::type('string'), - Argument::type('array') - )->will( - function ($args) use ($that, $io) { - $that->assertEquals('vcs', $args[0]); - $that->assertEquals( - 'https://github.com/bd808/composer-merge-plugin.git', - $args[1]['url'] - ); - - return new \Composer\Repository\VcsRepository( - $args[1], - $io->reveal(), - new \Composer\Config() - ); - } - ); - $repoManager->addRepository(Argument::any())->will( - function ($args) use ($that) { - $that->assertInstanceOf( - 'Composer\Repository\VcsRepository', - $args[0] - ); - } - ); - $this->composer->getRepositoryManager()->will( - function () use ($repoManager) { - return $repoManager->reveal(); - } - ); - - $root = $this->rootFromJson("{$dir}/composer.json"); - - $root->setRequires(Argument::type('array'))->will( - function ($args) use ($that) { - $requires = $args[0]; - $that->assertEquals(1, count($requires)); - $that->assertArrayHasKey( - 'wikimedia/composer-merge-plugin', - $requires - ); - } - ); - - $root->getDevRequires()->shouldNotBeCalled(); - $root->setDevRequires()->shouldNotBeCalled(); - - $root->setRepositories(Argument::type('array'))->will( - function ($args) use ($that) { - $repos = $args[0]; - $that->assertEquals(1, count($repos)); - } - ); - - $root->getSuggests()->shouldNotBeCalled(); - - $extraInstalls = $this->triggerPlugin($root->reveal(), $dir); - - $this->assertEquals(0, count($extraInstalls)); - } - - /** - * Given a root package - * and a composer.local.json with required packages - * When the plugin is run - * Then the root package should be updated with stability flags. - */ - public function testUpdateStabilityFlags() - { - $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->assertEquals(4, count($requires)); - $that->assertArrayHasKey('test/foo', $requires); - $that->assertArrayHasKey('test/bar', $requires); - $that->assertArrayHasKey('test/baz', $requires); - $that->assertArrayHasKey('test/xyzzy', $requires); - } - ); - - $root->getDevRequires()->shouldNotBeCalled(); - $root->setDevRequires(Argument::any())->shouldNotBeCalled(); - - $root->getRepositories()->shouldNotBeCalled(); - $root->setRepositories(Argument::any())->shouldNotBeCalled(); - - $root->getSuggests()->shouldNotBeCalled(); - $root->setSuggests(Argument::any())->shouldNotBeCalled(); - - $extraInstalls = $this->triggerPlugin($root->reveal(), $dir); - - $this->assertEquals(0, count($extraInstalls)); - } - - /** - * @param RootPackage $package - * @param string $directory Working directory for composer run - * @return array Constrains added by MergePlugin::onDependencySolve - */ - protected function triggerPlugin($package, $directory) - { - chdir($directory); - $this->composer->getPackage()->willReturn($package); - - $event = new CommandEvent( - ScriptEvents::PRE_INSTALL_CMD, - $this->composer->reveal(), - $this->io->reveal(), - true, //dev mode - array(), - array() - ); - $this->fixture->onInstallOrUpdate($event); - - $requestInstalls = array(); - $request = $this->prophesize('Composer\DependencyResolver\Request'); - $request->install(Argument::any(), Argument::any())->will( - function ($args) use (&$requestInstalls) { - $requestInstalls[] = $args; - } - ); - - $event = new InstallerEvent( - InstallerEvents::PRE_DEPENDENCIES_SOLVING, - $this->composer->reveal(), - $this->io->reveal(), - $this->prophesize('Composer\DependencyResolver\PolicyInterface')->reveal(), - $this->prophesize('Composer\DependencyResolver\Pool')->reveal(), - $this->prophesize('Composer\Repository\CompositeRepository')->reveal(), - $request->reveal(), - array() - ); - - $this->fixture->onDependencySolve($event); - return $requestInstalls; - } - - /** - * @param string $subdir - * @return string - */ - protected function fixtureDir($subdir) - { - return __DIR__ . "/fixtures/{$subdir}"; - } - - /** - * @param string $file - * @return ObjectProphecy - */ - protected function rootFromJson($file) - { - $that = $this; - $json = json_decode(file_get_contents($file), true); - $data = array_merge( - array( - 'repositories' => array(), - 'require' => array(), - 'require-dev' => array(), - 'suggest' => array(), - 'extra' => array(), - ), - $json - ); - - $root = $this->prophesize('Composer\Package\RootPackage'); - $root->getRequires()->willReturn($data['require'])->shouldBeCalled(); - $root->getDevRequires()->willReturn($data['require-dev']); - $root->getRepositories()->willReturn($data['repositories']); - $root->getSuggests()->willReturn($data['suggest']); - $root->getExtra()->willReturn($data['extra'])->shouldBeCalled(); - - $root->getStabilityFlags()->willReturn(array()); - $root->setStabilityFlags(Argument::type('array'))->will( - function ($args) use ($that) { - foreach ($args[0] as $key => $value) { - $that->assertContains($value, BasePackage::$stabilities); - } - } - ); - - return $root; - } -} -// vim:sw=4:ts=4:sts=4:et: diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.json deleted file mode 100644 index 719cce6..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extra": { - "merge-plugin": { - "include": "composer.local.json" - } - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.local.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.local.json deleted file mode 100644 index f2aa67b..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testMergedRepositories/composer.local.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/bd808/composer-merge-plugin.git" - } - ], - "require": { - "wikimedia/composer-merge-plugin": "dev-master#deadbeef" - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.json deleted file mode 100644 index 719cce6..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extra": { - "merge-plugin": { - "include": "composer.local.json" - } - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.local.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.local.json deleted file mode 100644 index 4928c06..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeNoConflicts/composer.local.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "monolog/monolog": "~1.0" - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.json deleted file mode 100644 index 9aac436..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "repositories": [ - { - "type": "vcs", - "url": "./.." - } - ], - "require": { - "wikimedia/composer-merge-plugin": "*@dev", - "monolog/monolog": "~1.0" - }, - "require-dev": { - "foo": "1.0.0" - }, - "extra": { - "merge-plugin": { - "include": [ - "composer.local.json" - ] - } - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.local.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.local.json deleted file mode 100644 index c9ed6da..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/composer.local.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "require": { - "monolog/monolog": "1.10.0" - }, - "require-dev": { - "xyzzy": "dev-master" - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/extensions/Foo/composer.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/extensions/Foo/composer.json deleted file mode 100644 index ac06e85..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testOneMergeWithConflicts/extensions/Foo/composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "require": { - "wikimedia/cdb": "~1.0.0", - "monolog/monolog": "1.10.0" - }, - "dev-require": { - "foo": "1.0.0" - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.json deleted file mode 100644 index 719cce6..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extra": { - "merge-plugin": { - "include": "composer.local.json" - } - } -} diff --git a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.local.json b/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.local.json deleted file mode 100644 index f7aa463..0000000 --- a/wikimedia/composer-merge-plugin/tests/phpunit/fixtures/testUpdateStabilityFlags/composer.local.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "require": { - "test/foo": "dev-master", - "test/bar": "~1.0@beta", - "test/baz": "0.1@alpha", - "test/xyzzy": "1.0.0-rc1" - } -} -- To view, visit https://gerrit.wikimedia.org/r/192046 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I65bf1e0d0e972846ed9e30761738aaf3a2127c2f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vendor Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits