@@ -31,7 +31,7 @@ public function dataCoerceCases()
3131 // toType
3232 'string ' => array (
3333 // fromType fromValue toValue valid Test Number
34- array ('string ' , '"string " ' , ' string ' , true ), // #0
34+ array ('string ' , '"ABC " ' , ' ABC ' , true ), // #0
3535 array ('integer ' , '45 ' , '45 ' , true ), // #1
3636 array ('boolean ' , 'true ' , 'true ' , true ), // #2
3737 array ('boolean ' , 'false ' , 'false ' , true ), // #3
@@ -55,7 +55,7 @@ public function dataCoerceCases()
5555 array ('boolean ' , 'true ' , true , true ), // #17
5656 array ('NULL ' , 'null ' , false , true ), // #18
5757 array ('array ' , '["true"] ' , true , true ), // #19
58- array ('object ' , '{"a":"b"} ' , null , false ), // #20
58+ array ('object ' , '{"a":"b"} ' , null , false ), // #20
5959 array ('string ' , '"" ' , null , false ), // #21
6060 array ('string ' , '"ABC" ' , null , false ), // #22
6161 array ('integer ' , '2 ' , null , false ), // #23
@@ -140,7 +140,7 @@ public function dataCoerceCases()
140140 $ tests [] = array (
141141 '{"properties":{"propertyOne":{"type":["object", "number", "string"]}}} ' ,
142142 '{"propertyOne":"42"} ' ,
143- 'string ' , 'integer ' , 42 , true , true
143+ 'string ' , 'integer ' , 42 , true , Constraint:: CHECK_MODE_EARLY_COERCE
144144 );
145145
146146 // #45 check multiple types (none valid)
@@ -154,11 +154,8 @@ public function dataCoerceCases()
154154 }
155155
156156 /** @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 )
158158 {
159- if ($ early ) {
160- $ this ->factory ->addConfig (Constraint::CHECK_MODE_EARLY_COERCE );
161- }
162159 $ validator = new Validator ($ this ->factory );
163160
164161 $ schema = json_decode ($ schema );
@@ -171,7 +168,7 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue,
171168 }
172169 $ this ->assertEquals ($ startType , $ type , "Incorrect type ' $ type': expected ' $ startType' " );
173170
174- $ validator ->validate ($ data , $ schema );
171+ $ validator ->validate ($ data , $ schema, $ this -> factory -> getConfig () | $ extraFlags );
175172
176173 // check validity
177174 if ($ valid ) {
@@ -199,8 +196,6 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue,
199196 $ this ->assertFalse ($ validator ->isValid (), 'Validation succeeded, but should have failed ' );
200197 $ this ->assertEquals (1 , count ($ validator ->getErrors ()));
201198 }
202-
203- $ this ->factory ->removeConfig (Constraint::CHECK_MODE_EARLY_COERCE );
204199 }
205200
206201 /** @dataProvider dataCoerceCases **/
0 commit comments