Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Fix callback not being applied #44

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
}