@@ -94,16 +94,18 @@ public function getValidTests()
94
94
/**
95
95
* @dataProvider getValidTests
96
96
*/
97
- public function testValidCases ($ input , $ schema , $ expectOutput = null )
97
+ public function testValidCases ($ input , $ schema , $ expectOutput = null , $ validator = null )
98
98
{
99
99
if (is_string ($ input )) {
100
100
$ inputDecoded = json_decode ($ input );
101
101
} else {
102
102
$ inputDecoded = $ input ;
103
103
}
104
104
105
- $ checkMode = Constraint::CHECK_MODE_APPLY_DEFAULTS ;
106
- $ validator = new Validator (new Factory (null , null , $ checkMode ));
105
+ if ($ validator === null ) {
106
+ $ checkMode = Constraint::CHECK_MODE_APPLY_DEFAULTS ;
107
+ $ validator = new Validator (new Factory (null , null , $ checkMode ));
108
+ }
107
109
$ validator ->coerce ($ inputDecoded , json_decode ($ schema ));
108
110
109
111
$ this ->assertTrue ($ validator ->isValid (), print_r ($ validator ->getErrors (), true ));
@@ -119,6 +121,9 @@ public function testValidCases($input, $schema, $expectOutput = null)
119
121
public function testValidCasesUsingAssoc ($ input , $ schema , $ expectOutput = null )
120
122
{
121
123
$ input = json_decode ($ input , true );
122
- self ::testValidCases ($ input , $ schema , $ expectOutput );
124
+
125
+ $ checkMode = Constraint::CHECK_MODE_APPLY_DEFAULTS | Constraint::CHECK_MODE_TYPE_CAST ;
126
+ $ validator = new Validator (new Factory (null , null , $ checkMode ));
127
+ self ::testValidCases ($ input , $ schema , $ expectOutput , $ validator );
123
128
}
124
129
}
0 commit comments