Skip to content

Commit

Permalink
Merge pull request #44 from laravel/fix-callback
Browse files Browse the repository at this point in the history
[2.x] Fix callback not being applied
  • Loading branch information
taylorotwell authored Dec 21, 2020
2 parents ea7fe02 + cb9325b commit 11ff3fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Channels/NexmoSmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function send($notifiable, Notification $notification)
];

if ($message->statusCallback) {
$payload['client_ref'] = $message->clientReference;
$payload['callback'] = $message->statusCallback;
}

return ($message->client ?? $this->nexmo)->message()->send($payload);
Expand Down
32 changes: 32 additions & 0 deletions tests/Channels/NexmoSmsChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ public function testSmsIsSentViaNexmoWithCustomClientFromAndClientRef()

$channel->send($notifiable, $notification);
}

public function testCallbackIsApplied()
{
$notification = new NotificationNexmoSmsChannelTestCallback;
$notifiable = new NotificationNexmoSmsChannelTestNotifiable;

$channel = new NexmoSmsChannel(
$nexmo = m::mock(Client::class), '4444444444'
);

$nexmo->shouldReceive('message->send')
->with([
'type' => 'text',
'from' => '4444444444',
'to' => '5555555555',
'text' => 'this is my message',
'client_ref' => '',
'callback' => 'https://example.com',
])
->once();

$channel->send($notifiable, $notification);
}
}

class NotificationNexmoSmsChannelTestNotifiable
Expand Down Expand Up @@ -238,3 +261,12 @@ public function toNexmo($notifiable)
->usingClient($this->client);
}
}

class NotificationNexmoSmsChannelTestCallback extends Notification
{
public function toNexmo($notifiable)
{
return (new NexmoMessage('this is my message'))
->statusCallback('https://example.com');
}
}

0 comments on commit 11ff3fc

Please sign in to comment.