File tree Expand file tree Collapse file tree 2 files changed +27
-53
lines changed Expand file tree Collapse file tree 2 files changed +27
-53
lines changed Original file line number Diff line number Diff line change @@ -221,5 +221,32 @@ public function testConstructorWithOptionalParams()
221
221
222
222
$ this ->assertEquals ('optional ' , $ objs [0 ]->foo );
223
223
}
224
+
225
+ /**
226
+ * Test for PHP7 nullable types like "?Object"
227
+ */
228
+ public function testObjectSetterTypeNullable ()
229
+ {
230
+ $ jm = new JsonMapper ();
231
+ $ sn = $ jm ->map (
232
+ json_decode ('{"typeNullableObject":null} ' ),
233
+ new JsonMapperTest_PHP7Object ()
234
+ );
235
+ $ this ->assertNull ($ sn ->typeNullableObject );
236
+ }
237
+
238
+ /**
239
+ * Test for non-nullable types like "@param object" with null value
240
+ */
241
+ public function testObjectSetterDocblockInvalidNull ()
242
+ {
243
+ $ this ->expectException (JsonMapper_Exception::class);
244
+ $ this ->expectExceptionMessage ('JSON property "nonNullableObject" in class "JsonMapperTest_PHP7Object" must not be NULL ' );
245
+ $ jm = new JsonMapper ();
246
+ $ sn = $ jm ->map (
247
+ json_decode ('{"nonNullableObject":null} ' ),
248
+ new JsonMapperTest_PHP7Object ()
249
+ );
250
+ }
224
251
}
225
252
?>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments