@@ -38,6 +38,31 @@ public function testCouldBeUnserializedFromJson()
38
38
$ this ->assertEquals ($ message , $ unserializedMessage );
39
39
}
40
40
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
+
41
66
public function testThrowIfMalformedJsonGivenOnUnsterilizedFromJson ()
42
67
{
43
68
$ this ->expectException (\InvalidArgumentException::class);
0 commit comments