@@ -108,4 +108,71 @@ public function testDeleteMessage()
108108 $ this ->mockClient ->expects ($ this ->once ())->method ('performHttpRequest ' )->with ("DELETE " , 'messages/message_id ' , null , null );
109109 $ this ->client ->messages ->delete ("message_id " );
110110 }
111+
112+ public function testCreateMessageResponse ()
113+ {
114+ $ message = new \MessageBird \Objects \Message ();
115+ $ message ->originator = 'MessageBird ' ;
116+ $ message ->recipients = [31612345678 ];
117+ $ message ->body = 'This is a test message. ' ;
118+
119+ $ this ->mockClient ->expects ($ this ->atLeastOnce ())->method ('performHttpRequest ' )->willReturn ([200 , '' , '{
120+ "id":"e8077d803532c0b5937c639b60216938",
121+ "href":"https://rest.messagebird.com/messages/e8077d803532c0b5937c639b60216938",
122+ "direction":"mt",
123+ "type":"sms",
124+ "originator":"YourName",
125+ "body":"This is a test message",
126+ "reference":null,
127+ "validity":null,
128+ "gateway":null,
129+ "typeDetails":{
130+
131+ },
132+ "datacoding":"plain",
133+ "mclass":1,
134+ "scheduledDatetime":null,
135+ "createdDatetime":"2015-07-03T07:55:31+00:00",
136+ "recipients":{
137+ "totalCount":1,
138+ "totalSentCount":1,
139+ "totalDeliveredCount":0,
140+ "totalDeliveryFailedCount":0,
141+ "items":[
142+ {
143+ "recipient":31612345678,
144+ "status":"sent",
145+ "statusDatetime":"2015-07-03T07:55:31+00:00"
146+ }
147+ ]
148+ },
149+ "reportUrl":null
150+ } ' ]);
151+
152+ /** @var \MessageBird\Objects\MessageResponse $messageResponse */
153+ $ messageResponse = $ this ->client ->messages ->create ($ message );
154+
155+ $ this ->assertSame ('e8077d803532c0b5937c639b60216938 ' , $ messageResponse ->id );
156+ $ this ->assertSame ('https://rest.messagebird.com/messages/e8077d803532c0b5937c639b60216938 ' , $ messageResponse ->href );
157+ $ this ->assertSame ('mt ' , $ messageResponse ->direction );
158+ $ this ->assertSame ('sms ' , $ messageResponse ->type );
159+ $ this ->assertSame ('YourName ' , $ messageResponse ->originator );
160+ $ this ->assertSame ('This is a test message ' , $ messageResponse ->body );
161+ $ this ->assertNull ($ messageResponse ->reference );
162+ $ this ->assertNull ($ messageResponse ->validity );
163+ $ this ->assertNull ($ messageResponse ->gateway );
164+ $ this ->assertEmpty ($ messageResponse ->typeDetails );
165+ $ this ->assertSame ('plain ' , $ messageResponse ->datacoding );
166+ $ this ->assertSame (1 , $ messageResponse ->mclass );
167+ $ this ->assertNull ($ messageResponse ->scheduledDatetime );
168+ $ this ->assertSame ('2015-07-03T07:55:31+00:00 ' , $ messageResponse ->createdDatetime );
169+ $ this ->assertSame (1 , $ messageResponse ->recipients ->totalCount );
170+ $ this ->assertSame (1 , $ messageResponse ->recipients ->totalSentCount );
171+ $ this ->assertSame (0 , $ messageResponse ->recipients ->totalDeliveredCount );
172+ $ this ->assertSame (0 , $ messageResponse ->recipients ->totalDeliveryFailedCount );
173+ $ this ->assertCount (1 , $ messageResponse ->recipients ->items );
174+ $ this ->assertSame (31612345678 , $ messageResponse ->recipients ->items [0 ]->recipient );
175+ $ this ->assertSame ('sent ' , $ messageResponse ->recipients ->items [0 ]->status );
176+ $ this ->assertSame ('2015-07-03T07:55:31+00:00 ' , $ messageResponse ->recipients ->items [0 ]->statusDatetime );
177+ }
111178}
0 commit comments