From fb54429941c9afa95f2002b7a9e7d24609cbca7e Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Mon, 9 Feb 2015 17:21:20 +0100 Subject: [PATCH] solve edge case for `composer remove vendor/pkg` --- .../Test/Json/JsonManipulatorTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index e3285efed..fdbc90af2 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -595,6 +595,44 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase ); } + public function testRemoveSubNodeFromRequire() + { + $manipulator = new JsonManipulator('{ + "repositories": [ + { + "package": { + "require": { + "this/should-not-end-up-in-root-require": "~2.0" + } + } + } + ], + "require": { + "package/a": "*", + "package/b": "*", + "package/c": "*" + } +}'); + + $this->assertTrue($manipulator->removeSubNode('require', 'package/c')); + $this->assertEquals('{ + "repositories": [ + { + "package": { + "require": { + "this/should-not-end-up-in-root-require": "~2.0" + } + } + } + ], + "require": { + "package/a": "*", + "package/b": "*" + } +} +', $manipulator->getContents()); + } + public function testAddRepositoryCanInitializeEmptyRepositories() { $manipulator = new JsonManipulator('{