Skip to content

Commit a877087

Browse files
committed
laravel-notification-channels#111 fix and add test for twiml call message
1 parent 321ec6c commit a877087

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

tests/Unit/IntegrationTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Twilio\Rest\Api\V2010\Account\MessageInstance;
1717
use Twilio\Rest\Api\V2010\Account\MessageList;
1818
use Twilio\Rest\Client as TwilioService;
19+
use Twilio\TwiML\VoiceResponse;
1920

2021
class IntegrationTest extends MockeryTestCase
2122
{
@@ -106,7 +107,7 @@ public function it_can_send_a_sms_message_using_alphanumeric_sender()
106107
/** @test */
107108
public function it_can_make_a_call()
108109
{
109-
$message = TwilioCallMessage::create('http://example.com');
110+
$message = TwilioCallMessage::create()->url('http://example.com');
110111
$this->notification->shouldReceive('toTwilio')->andReturn($message);
111112

112113
$config = new TwilioConfig([
@@ -122,6 +123,27 @@ public function it_can_make_a_call()
122123
$channel->send(new NotifiableWithAttribute(), $this->notification);
123124
}
124125

126+
/** @test */
127+
public function it_can_make_a_twiml_call()
128+
{
129+
$voice_message = new VoiceResponse();
130+
$voice_message->say('Message text');
131+
$message = TwilioCallMessage::create()->twiml($voice_message);
132+
$this->notification->shouldReceive('toTwilio')->andReturn($message);
133+
134+
$config = new TwilioConfig([
135+
'from' => '+31612345678',
136+
]);
137+
$twilio = new Twilio($this->twilioService, $config);
138+
$channel = new TwilioChannel($twilio, $this->events);
139+
140+
$this->callWillBeSentToTwilioWith('+22222222222', '+31612345678', [
141+
'twiml' => trim($message->content),
142+
]);
143+
144+
$channel->send(new NotifiableWithAttribute(), $this->notification);
145+
}
146+
125147
protected function smsMessageWillBeSentToTwilioWith(...$args)
126148
{
127149
$this->twilioService->messages->shouldReceive('create')

tests/Unit/TwilioTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function it_can_send_a_sms_message_to_twilio_with_messaging_service()
192192
/** @test */
193193
public function it_can_send_a_call_to_twilio()
194194
{
195-
$message = new TwilioCallMessage('http://example.com');
195+
$message = (new TwilioCallMessage())->url('http://example.com');
196196
$message->from = '+2222222222';
197197
$message->status(TwilioCallMessage::STATUS_CANCELED);
198198
$message->method('PUT');

0 commit comments

Comments
 (0)