ソースを参照

Enhancement: Assert that key is removed when value is null

Andreas Möller 7 年 前
コミット
79828f7543
1 ファイル変更16 行追加0 行削除
  1. 16 0
      tests/Composer/Test/Json/JsonManipulatorTest.php

+ 16 - 0
tests/Composer/Test/Json/JsonManipulatorTest.php

@@ -2310,6 +2310,22 @@ class JsonManipulatorTest extends TestCase
 ', $manipulator->getContents());
     }
 
+    public function testRemoveMainKeyRemovesKeyWhereValueIsNull()
+    {
+        $manipulator = new JsonManipulator(json_encode(array(
+            'foo' => 9000,
+            'bar' => null,
+        )));
+
+        $manipulator->removeMainKey('bar');
+
+        $expected = json_encode(array(
+            'foo' => 9000,
+        ));
+
+        $this->assertJsonStringEqualsJsonString($expected, $manipulator->getContents());
+    }
+
     public function testIndentDetection()
     {
         $manipulator = new JsonManipulator('{