Skip to content

Commit 5e4f1f8

Browse files
committed
Add new .length test to validate #60
#62
1 parent a386ada commit 5e4f1f8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/Galbar/JsonPath/JsonObjectLengthOperatorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,17 @@ public function testArrayLengthSmartGet()
315315
$result
316316
);
317317
}
318+
319+
/**
320+
* Validates behaviour described in issue https://github.com/Galbar/JsonPath-PHP/issues/62
321+
*
322+
* @throws InvalidJsonException
323+
*/
324+
public function testObjectHasPropertyLength()
325+
{
326+
$json = '{"box": {"length":[{"locale":null,"scope":null,"data":{"amount":"130.0000","unit":"CENTIMETER"}}]}}';
327+
$jsonPath = '$.box.length.*.data.amount';
328+
$jsonObject = new JsonObject($json);
329+
$this->assertEquals($jsonObject->get($jsonPath), array("130.0000"));
330+
}
318331
}

0 commit comments

Comments
 (0)