88
99class UndefinedConstraintTest extends BaseTestCase
1010{
11- /**
12- * @return array{}
13- */
14- public function getInvalidTests (): array
15- {
16- return [];
17- }
11+ public function getInvalidTests (): \Generator
12+ {}
1813
19- /**
20- * @return array<string, array{input: string, schema: string, checkMode?: int}>
21- */
22- public function getValidTests (): array
14+ public function getValidTests (): \Generator
2315 {
24- return [
25- 'oneOf with type coercion should not affect value passed to each sub schema (#790) ' => [
16+ yield 'oneOf with type coercion should not affect value passed to each sub schema (#790) ' => [
2617 'input ' => <<<JSON
2718 {
2819 "id": "LOC1",
@@ -33,8 +24,7 @@ public function getValidTests(): array
3324 }
3425 ]
3526 }
36- JSON
37- ,
27+ JSON ,
3828 'schema ' => <<<JSON
3929 {
4030 "title": "Location",
@@ -66,104 +56,98 @@ public function getValidTests(): array
6656 }
6757 }
6858 }
69- JSON
70- ,
71- 'checkMode ' => Constraint::CHECK_MODE_COERCE_TYPES
72- ],
73- 'oneOf with apply defaults should not affect value passed to each sub schema (#510) ' => [
74- 'input ' => <<<JSON
75- {"foo": {"name": "bar"}}
76- JSON
77- ,
78- 'schema ' => <<<JSON
79- {
80- "oneOf": [
81- {
82- "type": "object",
83- "properties": {
84- "foo": {
85- "type": "object",
86- "properties": {
87- "name": {"enum":["baz"],"default":"baz"},
88- "meta": {"enum":["baz"],"default":"baz"}
89- }
59+ JSON ,
60+ 'checkMode ' => Constraint::CHECK_MODE_COERCE_TYPES
61+ ];
62+ yield 'oneOf with apply defaults should not affect value passed to each sub schema (#510) ' => [
63+ 'input ' => <<<JSON
64+ {"foo": {"name": "bar"}}
65+ JSON ,
66+ 'schema ' => <<<JSON
67+ {
68+ "oneOf": [
69+ {
70+ "type": "object",
71+ "properties": {
72+ "foo": {
73+ "type": "object",
74+ "properties": {
75+ "name": {"enum":["baz"],"default":"baz"},
76+ "meta": {"enum":["baz"],"default":"baz"}
9077 }
9178 }
92- },
93- {
94- "type": "object",
95- "properties ": {
96- "foo ": {
97- "type ": "object",
98- "properties ": {
99- "name ": {"enum":["bar"],"default":"bar"},
100- "meta ": {"enum":["bar"],"default":"bar"}
101- }
79+ }
80+ },
81+ {
82+ "type ": "object",
83+ "properties ": {
84+ "foo ": {
85+ "type ": "object",
86+ "properties ": {
87+ "name ": {"enum":["bar"],"default":"bar"},
88+ "meta": {"enum":["bar"],"default":"bar" }
10289 }
10390 }
104- },
105- {
106- "type": "object",
107- "properties ": {
108- "foo ": {
109- "type ": "object",
110- "properties ": {
111- "name ": {"enum":["zip"],"default":"zip"},
112- "meta ": {"enum":["zip"],"default":"zip"}
113- }
91+ }
92+ },
93+ {
94+ "type ": "object",
95+ "properties ": {
96+ "foo ": {
97+ "type ": "object",
98+ "properties ": {
99+ "name ": {"enum":["zip"],"default":"zip"},
100+ "meta": {"enum":["zip"],"default":"zip" }
114101 }
115102 }
116103 }
117- ]
118- }
119- JSON
120- ,
121- 'checkMode ' => Constraint::CHECK_MODE_APPLY_DEFAULTS
122- ],
123- 'anyOf with apply defaults should not affect value passed to each sub schema (#711) ' => [
124- 'input ' => <<<JSON
125- {
126- "b": 2
127- }
128- JSON
129- ,
130- 'schema ' => <<<JSON
104+ }
105+ ]
106+ }
107+ JSON ,
108+ 'checkMode ' => Constraint::CHECK_MODE_APPLY_DEFAULTS
109+ ];
110+ yield 'anyOf with apply defaults should not affect value passed to each sub schema (#711) ' => [
111+ 'input ' => <<<JSON
112+ {
113+ "b": 2
114+ }
115+ JSON ,
116+ 'schema ' => <<<JSON
117+ {
118+ "anyOf": [
131119 {
132- "anyOf": [
133- {
134- "required": [ "a" ],
135- "properties": {
136- "a": {
137- "type": "integer"
138- },
139- "aDefault": {
140- "type": "integer",
141- "default": 1
142- }
120+ "required": [ "a" ],
121+ "pro": {
122+ "a": {
123+ "type": "integer"
124+ },
125+ "aDefault": {
126+ "type": "integer",
127+ "default": 1
128+ }
143129 },
144130 "type": "object",
145131 "additionalProperties": false
146132 },
147133 {
148134 "required": [ "b" ],
149135 "properties": {
150- "b": {
151- "type": "integer"
152- },
153- "bDefault": {
154- "type": "integer",
155- "default": 2
156- }
136+ "b": {
137+ "type": "integer"
138+ },
139+ "bDefault": {
140+ "type": "integer",
141+ "default": 2
142+ }
157143 },
158144 "type": "object",
159145 "additionalProperties": false
160146 }
161147 ]
162148 }
163- JSON
164- ,
165- 'checkMode ' => Constraint::CHECK_MODE_APPLY_DEFAULTS
166- ]
149+ JSON ,
150+ 'checkMode ' => Constraint::CHECK_MODE_APPLY_DEFAULTS
167151 ];
168152 }
169153}
0 commit comments