Browse Source

add test on remove mainkey at end of file

Deamon 7 years ago
parent
commit
3d753b117b
1 changed files with 30 additions and 0 deletions
  1. 30 0
      tests/Composer/Test/Json/JsonManipulatorTest.php

+ 30 - 0
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());
+
+    }
 }