From 3d753b117bdfdd67cd91be2b08d573390f26b05d Mon Sep 17 00:00:00 2001 From: Deamon Date: Mon, 11 Sep 2017 15:58:03 +0200 Subject: [PATCH] add test on remove mainkey at end of file --- .../Test/Json/JsonManipulatorTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index 097d7d9f4..5dd4f2c87 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -2331,4 +2331,34 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase } ', $manipulator->getContents()); } + + public function testRemoveMainKeyAtEndOfFile() + { + $manipulator = new JsonManipulator('{ + "require": { + "package/a": "*" + } +} +'); + $this->assertTrue($manipulator->addMainKey('homepage', 'http...')); + $this->assertTrue($manipulator->addMainKey('license', 'mit')); + $this->assertEquals('{ + "require": { + "package/a": "*" + }, + "homepage": "http...", + "license": "mit" +} +', $manipulator->getContents()); + + $this->assertTrue($manipulator->removeMainKey('homepage')); + $this->assertTrue($manipulator->removeMainKey('license')); + $this->assertEquals('{ + "require": { + "package/a": "*" + } +} +', $manipulator->getContents()); + + } }