@@ -130,7 +130,48 @@ public function dataCoerceCases()
130130 'string ' , 'integer ' , 42 , true
131131 );
132132
133- $ tests = array ();
133+ // #46 check coercion with "const"
134+ $ tests [] = array (
135+ '{"properties":{"propertyOne":{"type":"string","const":"42"}}} ' ,
136+ '{"propertyOne":42} ' ,
137+ 'integer ' , 'string ' , '42 ' , true
138+ );
139+
140+ // #47 check coercion with "const"
141+ $ tests [] = array (
142+ '{"properties":{"propertyOne":{"type":"number","const":42}}} ' ,
143+ '{"propertyOne":"42"} ' ,
144+ 'string ' , 'integer ' , 42 , true
145+ );
146+
147+ // #48 check boolean coercion with "const"
148+ $ tests [] = array (
149+ '{"properties":{"propertyOne":{"type":"boolean","const":false}}} ' ,
150+ '{"propertyOne":"false"} ' ,
151+ 'string ' , 'boolean ' , false , true
152+ );
153+
154+ // #49 check boolean coercion with "const"
155+ $ tests [] = array (
156+ '{"properties":{"propertyOne":{"type":"boolean","const":true}}} ' ,
157+ '{"propertyOne":"true"} ' ,
158+ 'string ' , 'boolean ' , true , true
159+ );
160+
161+ // #50 check boolean coercion with "const"
162+ $ tests [] = array (
163+ '{"properties":{"propertyOne":{"type":"boolean","const":true}}} ' ,
164+ '{"propertyOne":1} ' ,
165+ 'integer ' , 'boolean ' , true , true
166+ );
167+
168+ // #51 check boolean coercion with "const"
169+ $ tests [] = array (
170+ '{"properties":{"propertyOne":{"type":"boolean","const":false}}} ' ,
171+ '{"propertyOne":"false"} ' ,
172+ 'string ' , 'boolean ' , false , true
173+ );
174+
134175 foreach ($ types as $ toType => $ testCases ) {
135176 foreach ($ testCases as $ testCase ) {
136177 $ tests [] = array (
0 commit comments