@@ -10,144 +10,131 @@ class UndefinedConstraintTest extends BaseTestCase
1010{
1111 public function getInvalidTests (): \Generator
1212 {
13+ yield from [];
1314 }
1415
1516 public function getValidTests (): \Generator
1617 {
1718 yield 'oneOf with type coercion should not affect value passed to each sub schema (#790) ' => [
18- 'input ' => <<<JSON
19+ 'input ' => '{
20+ "id": "LOC1",
21+ "related_locations": [
1922 {
20- "id": "LOC1",
21- "related_locations": [
22- {
23- "latitude": "51.047598",
24- "longitude": "3.729943"
25- }
26- ]
23+ "latitude": "51.047598",
24+ "longitude": "3.729943"
2725 }
28- JSON ,
29- 'schema ' => <<<JSON
30- {
31- "title": "Location",
32- "type": "object",
33- "properties": {
34- "id": {
35- "type": "string"
26+ ]
27+ } ' ,
28+ 'schema ' => '{
29+ "title": "Location",
30+ "type": "object",
31+ "properties": {
32+ "id": {
33+ "type": "string"
34+ },
35+ "related_locations": {
36+ "oneOf": [
37+ {
38+ "type": "null"
3639 },
37- "related_locations": {
38- "oneOf": [
39- {
40- "type": "null"
41- },
42- {
43- "type": "array",
44- "items": {
45- "type": "object",
46- "properties": {
47- "latitude": {
48- "type": "string"
49- },
50- "longitude": {
51- "type": "string"
52- }
53- }
40+ {
41+ "type": "array",
42+ "items": {
43+ "type": "object",
44+ "properties": {
45+ "latitude": {
46+ "type": "string"
47+ },
48+ "longitude": {
49+ "type": "string"
5450 }
5551 }
56- ]
52+ }
5753 }
58- }
54+ ]
5955 }
60- JSON ,
56+ }
57+ } ' ,
6158 'checkMode ' => Constraint::CHECK_MODE_COERCE_TYPES
6259 ];
6360 yield 'oneOf with apply defaults should not affect value passed to each sub schema (#510) ' => [
64- 'input ' => <<<JSON
65- {"foo": {"name": "bar"}}
66- JSON ,
67- 'schema ' => <<<JSON
68- {
69- "oneOf": [
70- {
71- "type": "object",
72- "properties": {
73- "foo": {
74- "type": "object",
75- "properties": {
76- "name": {"enum":["baz"],"default":"baz"},
77- "meta": {"enum":["baz"],"default":"baz"}
78- }
61+ 'input ' => '{"foo": {"name": "bar"}} ' ,
62+ 'schema ' => '{
63+ "oneOf": [
64+ {
65+ "type": "object",
66+ "properties": {
67+ "foo": {
68+ "type": "object",
69+ "properties": {
70+ "name": {"enum":["baz"],"default":"baz"},
71+ "meta": {"enum":["baz"],"default":"baz"}
7972 }
8073 }
81- },
82- {
83- "type": "object",
84- "properties ": {
85- "foo ": {
86- "type ": "object",
87- "properties ": {
88- "name ": {"enum":["bar"],"default":"bar"},
89- "meta ": {"enum":["bar"],"default":"bar"}
90- }
74+ }
75+ },
76+ {
77+ "type ": "object",
78+ "properties ": {
79+ "foo ": {
80+ "type ": "object",
81+ "properties ": {
82+ "name ": {"enum":["bar"],"default":"bar"},
83+ "meta": {"enum":["bar"],"default":"bar" }
9184 }
9285 }
93- },
94- {
95- "type": "object",
96- "properties ": {
97- "foo ": {
98- "type ": "object",
99- "properties ": {
100- "name ": {"enum":["zip"],"default":"zip"},
101- "meta ": {"enum":["zip"],"default":"zip"}
102- }
86+ }
87+ },
88+ {
89+ "type ": "object",
90+ "properties ": {
91+ "foo ": {
92+ "type ": "object",
93+ "properties ": {
94+ "name ": {"enum":["zip"],"default":"zip"},
95+ "meta": {"enum":["zip"],"default":"zip" }
10396 }
10497 }
10598 }
106- ]
107- }
108- JSON ,
99+ }
100+ ]
101+ } ' ,
109102 'checkMode ' => Constraint::CHECK_MODE_APPLY_DEFAULTS
110103 ];
111104 yield 'anyOf with apply defaults should not affect value passed to each sub schema (#711) ' => [
112- 'input ' => <<<JSON
105+ 'input ' => '{ "b": 2 } ' ,
106+ 'schema ' => '{
107+ "anyOf": [
113108 {
114- "b": 2
115- }
116- JSON ,
117- 'schema ' => <<<JSON
109+ "required": [ "a" ],
110+ "pro": {
111+ "a": {
112+ "type": "integer"
113+ },
114+ "aDefault": {
115+ "type": "integer",
116+ "default": 1
117+ }
118+ },
119+ "type": "object",
120+ "additionalProperties": false
121+ },
118122 {
119- "anyOf": [
120- {
121- "required": [ "a" ],
122- "pro": {
123- "a": {
124- "type": "integer"
125- },
126- "aDefault": {
127- "type": "integer",
128- "default": 1
129- }
130- },
131- "type": "object",
132- "additionalProperties": false
123+ "required": [ "b" ],
124+ "properties": {
125+ "b": {
126+ "type": "integer"
133127 },
134- {
135- "required": [ "b" ],
136- "properties": {
137- "b": {
138- "type": "integer"
139- },
140- "bDefault": {
141- "type": "integer",
142- "default": 2
143- }
144- },
145- "type": "object",
146- "additionalProperties": false
128+ "bDefault": {
129+ "type": "integer",
130+ "default": 2
147131 }
148- ]
132+ },
133+ "type": "object",
134+ "additionalProperties": false
149135 }
150- JSON ,
136+ ]
137+ } ' ,
151138 'checkMode ' => Constraint::CHECK_MODE_APPLY_DEFAULTS
152139 ];
153140 }
0 commit comments