@@ -110,4 +110,116 @@ public function it_translates_non_requests_to_an_empty_string()
110
110
{
111
111
$ this ->assertEquals ('' , (string ) new Payload (null ));
112
112
}
113
+
114
+ /**
115
+ * @test
116
+ */
117
+ public function it_stringifies_a_simple_payload_to_a_string ()
118
+ {
119
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], 'content ' ))
120
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
121
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
122
+
123
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"content"} ' ;
124
+
125
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
126
+ }
127
+
128
+ /**
129
+ * @test
130
+ */
131
+ public function it_stringifies_a_payload_with_an_embedded_url_to_a_string ()
132
+ {
133
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], 'https://google.com ' ))
134
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
135
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
136
+
137
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"https://google.com"} ' ;
138
+
139
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
140
+ }
141
+
142
+ /**
143
+ * @test
144
+ */
145
+ public function it_stringifies_a_payload_with_the_ã_character_to_use_the_escaped_string ()
146
+ {
147
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], 'ã ' ))
148
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
149
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
150
+
151
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"ã"} ' ;
152
+
153
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
154
+ }
155
+
156
+ /**
157
+ * @test
158
+ */
159
+ public function it_stringifies_a_payload_with_the_好_character_to_use_the_escaped_string ()
160
+ {
161
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], '好 ' ))
162
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
163
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
164
+
165
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"好"} ' ;
166
+
167
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
168
+ }
169
+
170
+ /**
171
+ * @test
172
+ */
173
+ public function it_stringifies_a_json_payload_to_a_string ()
174
+ {
175
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], json_encode (['test ' => 'test ' ])))
176
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
177
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
178
+
179
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"{\"test\":\"test\"}"} ' ;
180
+
181
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
182
+ }
183
+
184
+ /**
185
+ * @test
186
+ */
187
+ public function it_stringifies_a_json_payload_with_the_ã_character_to_a_string ()
188
+ {
189
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], json_encode (['ã ' => 'ã ' ], JSON_UNESCAPED_UNICODE )))
190
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
191
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
192
+
193
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"{\"ã\":\"ã\"}"} ' ;
194
+
195
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
196
+ }
197
+
198
+ /**
199
+ * @test
200
+ */
201
+ public function it_stringifies_a_json_payload_with_the_好_character_to_a_string ()
202
+ {
203
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], json_encode (['好 ' => '好 ' ], JSON_UNESCAPED_UNICODE )))
204
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
205
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
206
+
207
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"{\"好\":\"好\"}"} ' ;
208
+
209
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
210
+ }
211
+
212
+ /**
213
+ * @test
214
+ */
215
+ public function it_stringifies_a_json_payload_with_a_url_to_a_string ()
216
+ {
217
+ $ request = (new GuzzleRequest ('GET ' , 'https://localhost ' , [], json_encode (['url ' => 'https://google.com ' ], JSON_UNESCAPED_UNICODE )))
218
+ ->withHeader ('X-SIGNED-ID ' , '303103f5-3dca-4704-96ad-860717769ec9 ' )
219
+ ->withHeader ('X-SIGNED-TIMESTAMP ' , '2018-04-06 20:34:47 ' );
220
+
221
+ $ expected = '{"id":"303103f5-3dca-4704-96ad-860717769ec9","method":"GET","timestamp":"2018-04-06 20:34:47","uri":"https://localhost","content":"{\"url\":\"https: \\\\/ \\\\/google.com\"}"} ' ;
222
+
223
+ $ this ->assertEquals ($ expected , (string ) new Payload ($ request ));
224
+ }
113
225
}
0 commit comments