From 752fa647049b9ecf32f7a31f0be5bb47be7c00aa Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Wed, 14 Nov 2012 09:03:11 -0800 Subject: [PATCH] Added addLink and removeLink to Configuration Source Interface * Added addLink() and removeLink() to `ConfigSourceInterface` * Added addLink() and removeLink() implementations to `JsonConfigSource` * Added tests (+ a ton of fixtures) for `JsonConfigSource` * Added additional docblocks * Minor PSR-1/PSR-2 fixes here and there --- src/Composer/Config/ConfigSourceInterface.php | 42 ++++ src/Composer/Config/JsonConfigSource.php | 42 +++- .../Fixtures/addLink/conflict-from-empty.json | 7 + .../conflict-from-oneOfEverything.json | 23 +++ .../conflict-from-twoOfEverything.json | 29 +++ .../Fixtures/addLink/provide-from-empty.json | 7 + .../addLink/provide-from-oneOfEverything.json | 23 +++ .../addLink/provide-from-twoOfEverything.json | 29 +++ .../Fixtures/addLink/replace-from-empty.json | 7 + .../addLink/replace-from-oneOfEverything.json | 23 +++ .../addLink/replace-from-twoOfEverything.json | 29 +++ .../addLink/require-dev-from-empty.json | 7 + .../require-dev-from-oneOfEverything.json | 23 +++ .../require-dev-from-twoOfEverything.json | 29 +++ .../Fixtures/addLink/require-from-empty.json | 7 + .../addLink/require-from-oneOfEverything.json | 23 +++ .../addLink/require-from-twoOfEverything.json | 29 +++ .../Fixtures/addLink/suggest-from-empty.json | 7 + .../addLink/suggest-from-oneOfEverything.json | 23 +++ .../addLink/suggest-from-twoOfEverything.json | 29 +++ .../Test/Config/Fixtures/composer-empty.json | 4 + .../Fixtures/composer-one-of-everything.json | 22 ++ .../Fixtures/composer-two-of-everything.json | 28 +++ .../removeLink/conflict-to-empty-after.json | 6 + .../removeLink/conflict-to-empty.json | 7 + .../conflict-to-oneOfEverything.json | 23 +++ .../conflict-to-twoOfEverything.json | 29 +++ .../removeLink/provide-to-empty-after.json | 6 + .../Fixtures/removeLink/provide-to-empty.json | 7 + .../provide-to-oneOfEverything.json | 23 +++ .../provide-to-twoOfEverything.json | 29 +++ .../removeLink/replace-to-empty-after.json | 6 + .../Fixtures/removeLink/replace-to-empty.json | 7 + .../replace-to-oneOfEverything.json | 23 +++ .../replace-to-twoOfEverything.json | 29 +++ .../require-dev-to-empty-after.json | 6 + .../removeLink/require-dev-to-empty.json | 7 + .../require-dev-to-oneOfEverything.json | 23 +++ .../require-dev-to-twoOfEverything.json | 29 +++ .../removeLink/require-to-empty-after.json | 6 + .../Fixtures/removeLink/require-to-empty.json | 7 + .../require-to-oneOfEverything.json | 23 +++ .../require-to-twoOfEverything.json | 29 +++ .../removeLink/suggest-to-empty-after.json | 6 + .../Fixtures/removeLink/suggest-to-empty.json | 7 + .../suggest-to-oneOfEverything.json | 23 +++ .../suggest-to-twoOfEverything.json | 29 +++ .../Test/Config/JsonConfigSourceTest.php | 188 ++++++++++++++++++ 48 files changed, 1069 insertions(+), 1 deletion(-) create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/conflict-from-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/conflict-from-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/conflict-from-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/provide-from-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/provide-from-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/provide-from-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/replace-from-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/replace-from-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/replace-from-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/require-from-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/require-from-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/require-from-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/suggest-from-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/suggest-from-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/addLink/suggest-from-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/composer-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/composer-one-of-everything.json create mode 100644 tests/Composer/Test/Config/Fixtures/composer-two-of-everything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty-after.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty-after.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/provide-to-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/provide-to-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty-after.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/replace-to-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/replace-to-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty-after.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty-after.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-to-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/require-to-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty-after.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-oneOfEverything.json create mode 100644 tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-twoOfEverything.json create mode 100644 tests/Composer/Test/Config/JsonConfigSourceTest.php diff --git a/src/Composer/Config/ConfigSourceInterface.php b/src/Composer/Config/ConfigSourceInterface.php index c67df4dd8..e1478dbbb 100644 --- a/src/Composer/Config/ConfigSourceInterface.php +++ b/src/Composer/Config/ConfigSourceInterface.php @@ -13,15 +13,57 @@ namespace Composer\Config; /** + * Configuration Source Interface + * * @author Jordi Boggiano + * @author Beau Simensen */ interface ConfigSourceInterface { + /** + * Add a repository + * + * @param string $name Name + * @param array $config Configuration + */ public function addRepository($name, $config); + /** + * Remove a repository + * + * @param string $name + */ public function removeRepository($name); + /** + * Add a config setting + * + * @param string $name Name + * @param string $value Value + */ public function addConfigSetting($name, $value); + /** + * Remove a config setting + * + * @param string $name + */ public function removeConfigSetting($name); + + /** + * Add a package link + * + * @param string $type Type (require, require-dev, provide, suggest, replace, conflict) + * @param string $name Name + * @param string $value Value + */ + public function addLink($type, $name, $value); + + /** + * Remove a package link + * + * @param string $type Type (require, require-dev, provide, suggest, replace, conflict) + * @param string $name Name + */ + public function removeLink($type, $name); } diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index 4293763b6..8b8b25e6f 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/src/Composer/Config/JsonConfigSource.php @@ -12,22 +12,33 @@ namespace Composer\Config; -use Composer\Json\JsonManipulator; use Composer\Json\JsonFile; +use Composer\Json\JsonManipulator; /** + * JSON Configuration Source + * * @author Jordi Boggiano + * @author Beau Simensen */ class JsonConfigSource implements ConfigSourceInterface { private $file; private $manipulator; + /** + * Constructor + * + * @param JsonFile $file + */ public function __construct(JsonFile $file) { $this->file = $file; } + /** + * {@inheritdoc} + */ public function addRepository($name, $config) { $this->manipulateJson('addRepository', $name, $config, function (&$config, $repo, $repoConfig) { @@ -35,6 +46,9 @@ class JsonConfigSource implements ConfigSourceInterface }); } + /** + * {@inheritdoc} + */ public function removeRepository($name) { $this->manipulateJson('removeRepository', $name, function (&$config, $repo) { @@ -42,6 +56,9 @@ class JsonConfigSource implements ConfigSourceInterface }); } + /** + * {@inheritdoc} + */ public function addConfigSetting($name, $value) { $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) { @@ -49,6 +66,9 @@ class JsonConfigSource implements ConfigSourceInterface }); } + /** + * {@inheritdoc} + */ public function removeConfigSetting($name) { $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) { @@ -56,6 +76,26 @@ class JsonConfigSource implements ConfigSourceInterface }); } + /** + * {@inheritdoc} + */ + public function addLink($type, $name, $value) + { + $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $key) { + $config[$type][$name] = $value; + }); + } + + /** + * {@inheritdoc} + */ + public function removeLink($type, $name) + { + $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $key) { + unset($config[$type][$name]); + }); + } + protected function manipulateJson($method, $args, $fallback) { $args = func_get_args(); diff --git a/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-empty.json b/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-empty.json new file mode 100644 index 000000000..a26153127 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "conflict": { + "my-vend/my-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-oneOfEverything.json new file mode 100644 index 000000000..2958555cf --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-twoOfEverything.json new file mode 100644 index 000000000..d3ced7b3b --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/conflict-from-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*", + "my-vend/my-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/provide-from-empty.json b/tests/Composer/Test/Config/Fixtures/addLink/provide-from-empty.json new file mode 100644 index 000000000..2192ed8da --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/provide-from-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "provide": { + "my-vend/my-lib-interface": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/provide-from-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/provide-from-oneOfEverything.json new file mode 100644 index 000000000..5d65cf35f --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/provide-from-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-lib-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/provide-from-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/provide-from-twoOfEverything.json new file mode 100644 index 000000000..64e917753 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/provide-from-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*", + "my-vend/my-lib-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/replace-from-empty.json b/tests/Composer/Test/Config/Fixtures/addLink/replace-from-empty.json new file mode 100644 index 000000000..7ee74641b --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/replace-from-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "replace": { + "my-vend/other-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/replace-from-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/replace-from-oneOfEverything.json new file mode 100644 index 000000000..60e20d28c --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/replace-from-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "my-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/replace-from-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/replace-from-twoOfEverything.json new file mode 100644 index 000000000..cc2d7a8fb --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/replace-from-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*", + "my-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-empty.json b/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-empty.json new file mode 100644 index 000000000..33e32fe75 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require-dev": { + "my-vend/my-lib-tests": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-oneOfEverything.json new file mode 100644 index 000000000..60c1a1854 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-twoOfEverything.json new file mode 100644 index 000000000..ff8863775 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/require-dev-from-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*", + "my-vend/my-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/require-from-empty.json b/tests/Composer/Test/Config/Fixtures/addLink/require-from-empty.json new file mode 100644 index 000000000..dbd210454 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/require-from-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-lib": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/require-from-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/require-from-oneOfEverything.json new file mode 100644 index 000000000..fce47d9b5 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/require-from-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/require-from-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/require-from-twoOfEverything.json new file mode 100644 index 000000000..5dabb7c73 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/require-from-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*", + "my-vend/my-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-empty.json b/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-empty.json new file mode 100644 index 000000000..4e12bb1fb --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "suggest": { + "my-vend/my-optional-extension": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-oneOfEverything.json new file mode 100644 index 000000000..e241f6b12 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-twoOfEverything.json new file mode 100644 index 000000000..7d908d96d --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/addLink/suggest-from-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*", + "my-vend/my-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/composer-empty.json b/tests/Composer/Test/Config/Fixtures/composer-empty.json new file mode 100644 index 000000000..ba03df2ff --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/composer-empty.json @@ -0,0 +1,4 @@ +{ + "name": "my-vend/my-app", + "license": "MIT" +} diff --git a/tests/Composer/Test/Config/Fixtures/composer-one-of-everything.json b/tests/Composer/Test/Config/Fixtures/composer-one-of-everything.json new file mode 100644 index 000000000..58e41d83a --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/composer-one-of-everything.json @@ -0,0 +1,22 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/composer-two-of-everything.json b/tests/Composer/Test/Config/Fixtures/composer-two-of-everything.json new file mode 100644 index 000000000..38badc025 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/composer-two-of-everything.json @@ -0,0 +1,28 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty-after.json b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty-after.json new file mode 100644 index 000000000..81fc11503 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty-after.json @@ -0,0 +1,6 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "conflict": { + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty.json b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty.json new file mode 100644 index 000000000..a26153127 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "conflict": { + "my-vend/my-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-oneOfEverything.json new file mode 100644 index 000000000..2958555cf --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-twoOfEverything.json new file mode 100644 index 000000000..d3ced7b3b --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/conflict-to-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*", + "my-vend/my-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty-after.json b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty-after.json new file mode 100644 index 000000000..99b4224b1 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty-after.json @@ -0,0 +1,6 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "provide": { + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty.json b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty.json new file mode 100644 index 000000000..2192ed8da --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "provide": { + "my-vend/my-lib-interface": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-oneOfEverything.json new file mode 100644 index 000000000..5d65cf35f --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-lib-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-twoOfEverything.json new file mode 100644 index 000000000..64e917753 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/provide-to-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*", + "my-vend/my-lib-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty-after.json b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty-after.json new file mode 100644 index 000000000..6430a49fc --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty-after.json @@ -0,0 +1,6 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "replace": { + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty.json b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty.json new file mode 100644 index 000000000..7ee74641b --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "replace": { + "my-vend/other-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-oneOfEverything.json new file mode 100644 index 000000000..60e20d28c --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "my-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-twoOfEverything.json new file mode 100644 index 000000000..cc2d7a8fb --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/replace-to-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*", + "my-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty-after.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty-after.json new file mode 100644 index 000000000..4058e5a20 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty-after.json @@ -0,0 +1,6 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require-dev": { + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty.json new file mode 100644 index 000000000..33e32fe75 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require-dev": { + "my-vend/my-lib-tests": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-oneOfEverything.json new file mode 100644 index 000000000..60c1a1854 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-twoOfEverything.json new file mode 100644 index 000000000..ff8863775 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-dev-to-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*", + "my-vend/my-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty-after.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty-after.json new file mode 100644 index 000000000..4f244ff96 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty-after.json @@ -0,0 +1,6 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty.json new file mode 100644 index 000000000..dbd210454 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-lib": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-to-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-oneOfEverything.json new file mode 100644 index 000000000..fce47d9b5 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/require-to-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-twoOfEverything.json new file mode 100644 index 000000000..5dabb7c73 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/require-to-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*", + "my-vend/my-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty-after.json b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty-after.json new file mode 100644 index 000000000..21d79e2f4 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty-after.json @@ -0,0 +1,6 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "suggest": { + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty.json b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty.json new file mode 100644 index 000000000..4e12bb1fb --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-empty.json @@ -0,0 +1,7 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "suggest": { + "my-vend/my-optional-extension": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-oneOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-oneOfEverything.json new file mode 100644 index 000000000..e241f6b12 --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-oneOfEverything.json @@ -0,0 +1,23 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-twoOfEverything.json b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-twoOfEverything.json new file mode 100644 index 000000000..7d908d96d --- /dev/null +++ b/tests/Composer/Test/Config/Fixtures/removeLink/suggest-to-twoOfEverything.json @@ -0,0 +1,29 @@ +{ + "name": "my-vend/my-app", + "license": "MIT", + "require": { + "my-vend/my-other-lib": "1.*", + "my-vend/my-yet-another-lib": "1.*" + }, + "require-dev": { + "my-vend/my-other-lib-tests": "1.*", + "my-vend/my-yet-another-lib-tests": "1.*" + }, + "provide": { + "my-vend/my-other-interface": "1.*", + "my-vend/my-yet-another-interface": "1.*" + }, + "suggest": { + "my-vend/my-other-optional-extension": "1.*", + "my-vend/my-yet-another-optional-extension": "1.*", + "my-vend/my-optional-extension": "1.*" + }, + "replace": { + "other-vend/other-app": "1.*", + "other-vend/yet-another-app": "1.*" + }, + "conflict": { + "my-vend/my-other-old-app": "1.*", + "my-vend/my-yet-another-old-app": "1.*" + } +} diff --git a/tests/Composer/Test/Config/JsonConfigSourceTest.php b/tests/Composer/Test/Config/JsonConfigSourceTest.php new file mode 100644 index 000000000..fc714c9bc --- /dev/null +++ b/tests/Composer/Test/Config/JsonConfigSourceTest.php @@ -0,0 +1,188 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\Json; + +use Composer\Config\JsonConfigSource; +use Composer\Json\JsonFile; +use Composer\Util\Filesystem; + +/** + * JsonConfigSource Test + * + * @author Beau Simensen + */ +class JsonConfigSourceTest extends \PHPUnit_Framework_TestCase +{ + private $workingDir; + + protected function fixturePath($name) + { + return __DIR__.'/Fixtures/'.$name; + } + + protected function setUp() + { + $this->fs = new Filesystem; + $this->workingDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest'; + $this->fs->ensureDirectoryExists($this->workingDir); + } + + protected function tearDown() + { + if (is_dir($this->workingDir)) { + $this->fs->removeDirectory($this->workingDir); + } + } + + protected function addLinkDataArguments($type, $name, $value, $fixtureBasename, $before) + { + return array( + $before, + $type, + $name, + $value, + $this->fixturePath('addLink/'.$fixtureBasename.'.json'), + ); + + } + + /** + * Provide data for testAddLink + * + * @return array + */ + public function provideAddLinkData() + { + $empty = $this->fixturePath('composer-empty.json'); + $oneOfEverything = $this->fixturePath('composer-one-of-everything.json'); + $twoOfEverything = $this->fixturePath('composer-two-of-everything.json'); + + return array( + + $this->addLinkDataArguments('require', 'my-vend/my-lib', '1.*', 'require-from-empty', $empty), + $this->addLinkDataArguments('require', 'my-vend/my-lib', '1.*', 'require-from-oneOfEverything', $oneOfEverything), + $this->addLinkDataArguments('require', 'my-vend/my-lib', '1.*', 'require-from-twoOfEverything', $twoOfEverything), + + $this->addLinkDataArguments('require-dev', 'my-vend/my-lib-tests', '1.*', 'require-dev-from-empty', $empty), + $this->addLinkDataArguments('require-dev', 'my-vend/my-lib-tests', '1.*', 'require-dev-from-oneOfEverything', $oneOfEverything), + $this->addLinkDataArguments('require-dev', 'my-vend/my-lib-tests', '1.*', 'require-dev-from-twoOfEverything', $twoOfEverything), + + $this->addLinkDataArguments('provide', 'my-vend/my-lib-interface', '1.*', 'provide-from-empty', $empty), + $this->addLinkDataArguments('provide', 'my-vend/my-lib-interface', '1.*', 'provide-from-oneOfEverything', $oneOfEverything), + $this->addLinkDataArguments('provide', 'my-vend/my-lib-interface', '1.*', 'provide-from-twoOfEverything', $twoOfEverything), + + $this->addLinkDataArguments('suggest', 'my-vend/my-optional-extension', '1.*', 'suggest-from-empty', $empty), + $this->addLinkDataArguments('suggest', 'my-vend/my-optional-extension', '1.*', 'suggest-from-oneOfEverything', $oneOfEverything), + $this->addLinkDataArguments('suggest', 'my-vend/my-optional-extension', '1.*', 'suggest-from-twoOfEverything', $twoOfEverything), + + $this->addLinkDataArguments('replace', 'my-vend/other-app', '1.*', 'replace-from-empty', $empty), + $this->addLinkDataArguments('replace', 'my-vend/other-app', '1.*', 'replace-from-oneOfEverything', $oneOfEverything), + $this->addLinkDataArguments('replace', 'my-vend/other-app', '1.*', 'replace-from-twoOfEverything', $twoOfEverything), + + $this->addLinkDataArguments('conflict', 'my-vend/my-old-app', '1.*', 'conflict-from-empty', $empty), + $this->addLinkDataArguments('conflict', 'my-vend/my-old-app', '1.*', 'conflict-from-oneOfEverything', $oneOfEverything), + $this->addLinkDataArguments('conflict', 'my-vend/my-old-app', '1.*', 'conflict-from-twoOfEverything', $twoOfEverything), + ); + } + + /** + * Test addLink() + * + * @param string $sourceFile Source file + * @param string $type Type (require, require-dev, provide, suggest, replace, conflict) + * @param string $name Name + * @param string $value Value + * @param string $compareAgainst File to compare against after making changes + * + * @dataProvider provideAddLinkData + */ + public function testAddLink($sourceFile, $type, $name, $value, $compareAgainst) + { + $composerJson = $this->workingDir.'/composer.json'; + copy($sourceFile, $composerJson); + $jsonConfigSource = new JsonConfigSource(new JsonFile($composerJson)); + + $jsonConfigSource->addLink($type, $name, $value); + + $this->assertFileEquals($compareAgainst, $composerJson); + } + + protected function removeLinkDataArguments($type, $name, $fixtureBasename, $after = null) + { + return array( + $this->fixturePath('removeLink/'.$fixtureBasename.'.json'), + $type, + $name, + $after ?: $this->fixturePath('removeLink/'.$fixtureBasename.'-after.json'), + ); + + } + + /** + * Provide data for testRemoveLink + * + * @return array + */ + public function provideRemoveLinkData() + { + $oneOfEverything = $this->fixturePath('composer-one-of-everything.json'); + $twoOfEverything = $this->fixturePath('composer-two-of-everything.json'); + + return array( + $this->removeLinkDataArguments('require', 'my-vend/my-lib', 'require-to-empty'), + $this->removeLinkDataArguments('require', 'my-vend/my-lib', 'require-to-oneOfEverything', $oneOfEverything), + $this->removeLinkDataArguments('require', 'my-vend/my-lib', 'require-to-twoOfEverything', $twoOfEverything), + + $this->removeLinkDataArguments('require-dev', 'my-vend/my-lib-tests', 'require-dev-to-empty'), + $this->removeLinkDataArguments('require-dev', 'my-vend/my-lib-tests', 'require-dev-to-oneOfEverything', $oneOfEverything), + $this->removeLinkDataArguments('require-dev', 'my-vend/my-lib-tests', 'require-dev-to-twoOfEverything', $twoOfEverything), + + $this->removeLinkDataArguments('provide', 'my-vend/my-lib-interface', 'provide-to-empty'), + $this->removeLinkDataArguments('provide', 'my-vend/my-lib-interface', 'provide-to-oneOfEverything', $oneOfEverything), + $this->removeLinkDataArguments('provide', 'my-vend/my-lib-interface', 'provide-to-twoOfEverything', $twoOfEverything), + + $this->removeLinkDataArguments('suggest', 'my-vend/my-optional-extension', 'suggest-to-empty'), + $this->removeLinkDataArguments('suggest', 'my-vend/my-optional-extension', 'suggest-to-oneOfEverything', $oneOfEverything), + $this->removeLinkDataArguments('suggest', 'my-vend/my-optional-extension', 'suggest-to-twoOfEverything', $twoOfEverything), + + $this->removeLinkDataArguments('replace', 'my-vend/other-app', 'replace-to-empty'), + $this->removeLinkDataArguments('replace', 'my-vend/other-app', 'replace-to-oneOfEverything', $oneOfEverything), + $this->removeLinkDataArguments('replace', 'my-vend/other-app', 'replace-to-twoOfEverything', $twoOfEverything), + + $this->removeLinkDataArguments('conflict', 'my-vend/my-old-app', 'conflict-to-empty'), + $this->removeLinkDataArguments('conflict', 'my-vend/my-old-app', 'conflict-to-oneOfEverything', $oneOfEverything), + $this->removeLinkDataArguments('conflict', 'my-vend/my-old-app', 'conflict-to-twoOfEverything', $twoOfEverything), + ); + } + + /** + * Test removeLink() + * + * @param string $sourceFile Source file + * @param string $type Type (require, require-dev, provide, suggest, replace, conflict) + * @param string $name Name + * @param string $compareAgainst File to compare against after making changes + * + * @dataProvider provideRemoveLinkData + */ + public function testRemoveLink($sourceFile, $type, $name, $compareAgainst) + { + $composerJson = $this->workingDir.'/composer.json'; + copy($sourceFile, $composerJson); + $jsonConfigSource = new JsonConfigSource(new JsonFile($composerJson)); + + $jsonConfigSource->removeLink($type, $name); + + $this->assertFileEquals($compareAgainst, $composerJson); + } +}