@@ -174,6 +174,56 @@ public function testSendWithNotification()
174
174
$ this ->assertSame ('1503435956.000247 ' , $ sentMessage ->getMessageId ());
175
175
}
176
176
177
+ /**
178
+ * @testWith [true]
179
+ * [false]
180
+ */
181
+ public function testSendWithBooleanOptionValue (bool $ value )
182
+ {
183
+ $ channel = 'testChannel ' ;
184
+ $ message = 'testMessage ' ;
185
+
186
+ $ response = $ this ->createMock (ResponseInterface::class);
187
+
188
+ $ response ->expects ($ this ->exactly (2 ))
189
+ ->method ('getStatusCode ' )
190
+ ->willReturn (200 );
191
+
192
+ $ response ->expects ($ this ->once ())
193
+ ->method ('getContent ' )
194
+ ->willReturn (json_encode (['ok ' => true , 'ts ' => '1503435956.000247 ' ]));
195
+
196
+ $ options = new SlackOptions ();
197
+ $ options ->asUser ($ value );
198
+ $ options ->linkNames ($ value );
199
+ $ options ->mrkdwn ($ value );
200
+ $ options ->unfurlLinks ($ value );
201
+ $ options ->unfurlMedia ($ value );
202
+ $ notification = new Notification ($ message );
203
+ $ chatMessage = ChatMessage::fromNotification ($ notification );
204
+ $ chatMessage ->options ($ options );
205
+
206
+ $ expectedBody = json_encode ([
207
+ 'as_user ' => $ value ,
208
+ 'channel ' => $ channel ,
209
+ 'link_names ' => $ value ,
210
+ 'mrkdwn ' => $ value ,
211
+ 'text ' => $ message ,
212
+ 'unfurl_links ' => $ value ,
213
+ 'unfurl_media ' => $ value ,
214
+ ]);
215
+
216
+ $ client = new MockHttpClient (function (string $ method , string $ url , array $ options = []) use ($ response , $ expectedBody ): ResponseInterface {
217
+ $ this ->assertJsonStringEqualsJsonString ($ expectedBody , $ options ['body ' ]);
218
+
219
+ return $ response ;
220
+ });
221
+
222
+ $ transport = self ::createTransport ($ client , $ channel );
223
+
224
+ $ transport ->send ($ chatMessage );
225
+ }
226
+
177
227
public function testSendWithInvalidOptions ()
178
228
{
179
229
$ this ->expectException (LogicException::class);
0 commit comments