File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \Component \Notifier \Bridge \Sweego \Tests ;
1313
1414use Symfony \Component \HttpClient \MockHttpClient ;
15+ use Symfony \Component \HttpClient \Response \JsonMockResponse ;
1516use Symfony \Component \Notifier \Bridge \Sweego \SweegoTransport ;
1617use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
1718use Symfony \Component \Notifier \Message \ChatMessage ;
@@ -68,4 +69,22 @@ public function testSendWithInvalidMessageType()
6869 $ message = $ this ->createMock (MessageInterface::class);
6970 $ transport ->send ($ message );
7071 }
72+
73+ public function testSendSmsMessage ()
74+ {
75+ $ client = new MockHttpClient (function ($ method , $ url , $ options ) {
76+ $ this ->assertSame ('POST ' , $ method );
77+ $ this ->assertSame ('https://api.sweego.io/send ' , $ url );
78+
79+ $ body = json_decode ($ options ['body ' ], true );
80+ $ this ->assertSame ('sms ' , $ body ['channel ' ]);
81+
82+ return new JsonMockResponse (['swg_uids ' => ['123 ' ]]);
83+ });
84+
85+ $ transport = self ::createTransport ($ client );
86+ $ sentMessage = $ transport ->send (new SmsMessage ('0611223344 ' , 'Hello! ' ));
87+
88+ $ this ->assertSame ('123 ' , $ sentMessage ->getMessageId ());
89+ }
7190}
You can’t perform that action at this time.
0 commit comments