Skip to content

Commit

Permalink
Updated code style, added new test, fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Braunson committed Jul 28, 2019
1 parent c34618c commit 638d1cc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Channels/NexmoSmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function send($notifiable, Notification $notification)
'from' => $message->from ?: $this->from,
'to' => $to,
'text' => trim($message->content),
'client_ref' => $message->client_ref,
'client_ref' => $message->clientRef,
]);
}
}
8 changes: 4 additions & 4 deletions src/Messages/NexmoMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NexmoMessage
*
* @var string
*/
public $client_ref = '';
public $clientRef = '';

/**
* Create a new message instance.
Expand Down Expand Up @@ -84,12 +84,12 @@ public function unicode()
/**
* Set the client reference (up to 40 characters).
*
* @param string $client_ref
* @param string $clientRef
* @return $this
*/
public function clientRef($client_ref)
public function clientRef($clientRef)
{
$this->client_ref = $client_ref;
$this->clientRef = $clientRef;

return $this;
}
Expand Down
30 changes: 30 additions & 0 deletions tests/NotificationNexmoChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function testSmsIsSentViaNexmo()
'from' => '4444444444',
'to' => '5555555555',
'text' => 'this is my message',
'client_ref' => '',
]);

$channel->send($notifiable, $notification);
Expand All @@ -50,6 +51,27 @@ public function testSmsIsSentViaNexmoWithCustomFrom()
'from' => '5554443333',
'to' => '5555555555',
'text' => 'this is my message',
'client_ref' => '',
]);

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

public function testSmsIsSentViaNexmoWithCustomFromAndClientRef()
{
$notification = new NotificationNexmoChannelTestCustomFromAndClientRefNotification;
$notifiable = new NotificationNexmoChannelTestNotifiable;

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

$nexmo->shouldReceive('message->send')->with([
'type' => 'unicode',
'from' => '5554443333',
'to' => '5555555555',
'text' => 'this is my message',
'client_ref' => '11',
]);

$channel->send($notifiable, $notification);
Expand Down Expand Up @@ -78,3 +100,11 @@ public function toNexmo($notifiable)
return (new NexmoMessage('this is my message'))->from('5554443333')->unicode();
}
}

class NotificationNexmoChannelTestCustomFromAndClientRefNotification extends Notification
{
public function toNexmo($notifiable)
{
return (new NexmoMessage('this is my message'))->from('5554443333')->unicode()->clientRef('11');
}
}

0 comments on commit 638d1cc

Please sign in to comment.