@@ -38,6 +38,31 @@ public function testCouldBeUnserializedFromJson()
3838 $ this ->assertEquals ($ message , $ unserializedMessage );
3939 }
4040
41+ public function testMessageEntityCouldBeUnserializedFromJson ()
42+ {
43+ $ json = '{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"}} ' ;
44+
45+ $ unserializedMessage = GpsMessage::jsonUnserialize ($ json );
46+
47+ $ this ->assertInstanceOf (GpsMessage::class, $ unserializedMessage );
48+ $ decoded = json_decode ($ json , true );
49+ $ this ->assertEquals ($ decoded ['body ' ], $ unserializedMessage ->getBody ());
50+ $ this ->assertEquals ($ decoded ['properties ' ], $ unserializedMessage ->getProperties ());
51+ $ this ->assertEquals ($ decoded ['headers ' ], $ unserializedMessage ->getHeaders ());
52+ }
53+
54+ public function testMessagePayloadCouldBeUnserializedFromJson ()
55+ {
56+ $ json = '{"theBodyPropFoo":"theBodyPropVal"} ' ;
57+
58+ $ unserializedMessage = GpsMessage::jsonUnserialize ($ json );
59+
60+ $ this ->assertInstanceOf (GpsMessage::class, $ unserializedMessage );
61+ $ this ->assertEquals ($ json , $ unserializedMessage ->getBody ());
62+ $ this ->assertEquals ([], $ unserializedMessage ->getProperties ());
63+ $ this ->assertEquals ([], $ unserializedMessage ->getHeaders ());
64+ }
65+
4166 public function testThrowIfMalformedJsonGivenOnUnsterilizedFromJson ()
4267 {
4368 $ this ->expectException (\InvalidArgumentException::class);
0 commit comments