Skip to content

Commit 4b18271

Browse files
committed
add tests
1 parent 8be9120 commit 4b18271

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/JsonSchema/Tests/Constraints/RequiredPropertyTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,39 @@ public function testErrorPropertyIsPopulatedForRequiredIfMissingInInput()
3838
$this->assertErrorHasExpectedPropertyValue($error, "foo");
3939
}
4040

41+
public function testPathErrorPropertyIsPopulatedForRequiredIfMissingInInput()
42+
{
43+
$validator = new UndefinedConstraint();
44+
$document = json_decode(
45+
'{
46+
"foo": [{"baz": 1.5}]
47+
}'
48+
);
49+
$schema = json_decode(
50+
'{
51+
"type": "object",
52+
"properties": {
53+
"foo": {
54+
"type": "array",
55+
"items": {
56+
"type": "object",
57+
"properties": {
58+
"bar": {"type": "number"},
59+
"baz": {"type": "number"}
60+
},
61+
"required": ["bar"]
62+
}
63+
}
64+
},
65+
"required": ["foo"]
66+
}'
67+
);
68+
69+
$validator->check($document, $schema);
70+
$error = $validator->getErrors();
71+
$this->assertErrorHasExpectedPropertyValue($error, "foo[0].bar");
72+
}
73+
4174
public function testErrorPropertyIsPopulatedForRequiredIfEmptyValueInInput()
4275
{
4376
$validator = new UndefinedConstraint();

0 commit comments

Comments
 (0)