@@ -31,7 +31,7 @@ public function dataCoerceCases()
31
31
// toType
32
32
'string ' => array (
33
33
// fromType fromValue toValue valid Test Number
34
- array ('string ' , '"string " ' , ' string ' , true ), // #0
34
+ array ('string ' , '"ABC " ' , ' ABC ' , true ), // #0
35
35
array ('integer ' , '45 ' , '45 ' , true ), // #1
36
36
array ('boolean ' , 'true ' , 'true ' , true ), // #2
37
37
array ('boolean ' , 'false ' , 'false ' , true ), // #3
@@ -55,7 +55,7 @@ public function dataCoerceCases()
55
55
array ('boolean ' , 'true ' , true , true ), // #17
56
56
array ('NULL ' , 'null ' , false , true ), // #18
57
57
array ('array ' , '["true"] ' , true , true ), // #19
58
- array ('object ' , '{"a":"b"} ' , null , false ), // #20
58
+ array ('object ' , '{"a":"b"} ' , null , false ), // #20
59
59
array ('string ' , '"" ' , null , false ), // #21
60
60
array ('string ' , '"ABC" ' , null , false ), // #22
61
61
array ('integer ' , '2 ' , null , false ), // #23
@@ -140,7 +140,7 @@ public function dataCoerceCases()
140
140
$ tests [] = array (
141
141
'{"properties":{"propertyOne":{"type":["object", "number", "string"]}}} ' ,
142
142
'{"propertyOne":"42"} ' ,
143
- 'string ' , 'integer ' , 42 , true , true
143
+ 'string ' , 'integer ' , 42 , true , Constraint:: CHECK_MODE_EARLY_COERCE
144
144
);
145
145
146
146
// #45 check multiple types (none valid)
@@ -154,11 +154,8 @@ public function dataCoerceCases()
154
154
}
155
155
156
156
/** @dataProvider dataCoerceCases **/
157
- public function testCoerceCases ($ schema , $ data , $ startType , $ endType , $ endValue , $ valid , $ early = false , $ assoc = false )
157
+ public function testCoerceCases ($ schema , $ data , $ startType , $ endType , $ endValue , $ valid , $ extraFlags = 0 , $ assoc = false )
158
158
{
159
- if ($ early ) {
160
- $ this ->factory ->addConfig (Constraint::CHECK_MODE_EARLY_COERCE );
161
- }
162
159
$ validator = new Validator ($ this ->factory );
163
160
164
161
$ schema = json_decode ($ schema );
@@ -171,7 +168,7 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue,
171
168
}
172
169
$ this ->assertEquals ($ startType , $ type , "Incorrect type ' $ type': expected ' $ startType' " );
173
170
174
- $ validator ->validate ($ data , $ schema );
171
+ $ validator ->validate ($ data , $ schema, $ this -> factory -> getConfig () | $ extraFlags );
175
172
176
173
// check validity
177
174
if ($ valid ) {
@@ -199,8 +196,6 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue,
199
196
$ this ->assertFalse ($ validator ->isValid (), 'Validation succeeded, but should have failed ' );
200
197
$ this ->assertEquals (1 , count ($ validator ->getErrors ()));
201
198
}
202
-
203
- $ this ->factory ->removeConfig (Constraint::CHECK_MODE_EARLY_COERCE );
204
199
}
205
200
206
201
/** @dataProvider dataCoerceCases **/
0 commit comments