Skip to content

Commit

Permalink
Merge pull request #1 from xefi/feature/style-ci-config
Browse files Browse the repository at this point in the history
Feature/style ci config
  • Loading branch information
GautierDele authored Mar 20, 2024
2 parents f30758e + ac28d61 commit 22f3e99
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
tests:
runs-on: ubuntu-23.10
runs-on: ubuntu-22.04

strategy:
fail-fast: true
Expand Down
4 changes: 0 additions & 4 deletions .styleci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion config/sms-factor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
*/

'api_token' => env('SMS_FACTOR_TOKEN'),
];
];
21 changes: 11 additions & 10 deletions src/Channels/SmsFactorSmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

namespace Xefi\SmsFactor\Channels;

use Xefi\SmsFactor\Messages\SmsFactorMessage;
use SMSFactor\Message;
use Illuminate\Notifications\Notification;
use SMSFactor\Message;
use Xefi\SmsFactor\Messages\SmsFactorMessage;

class SmsFactorSmsChannel extends Notification
{
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
*
* @return \SmsFactor\ApiResponse
*/
public function send($notifiable, Notification $notification)
{
if (! $to = $notifiable->routeNotificationFor('sms-factor', $notification)) {
if (!$to = $notifiable->routeNotificationFor('sms-factor', $notification)) {
return;
}

Expand All @@ -28,12 +29,12 @@ public function send($notifiable, Notification $notification)
}

return Message::send([
'to' => $to,
'text' => trim($message->text),
'delay' => $message->delay,
'to' => $to,
'text' => trim($message->text),
'delay' => $message->delay,
'pushtype' => $message->pushtype ?? null,
'sender' => $message->sender ?? config('sms-factor.sms_from'),
'sender' => $message->sender ?? config('sms-factor.sms_from'),
'gsmsmsid' => $message->gsmsmsid ?? null,
]);
}
}
}
17 changes: 11 additions & 6 deletions src/Messages/SmsFactorMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class SmsFactorMessage
/**
* Set the message text.
*
* @param string $text
* @param string $text
*
* @return $this
*/
public function text($text)
Expand All @@ -57,7 +58,8 @@ public function text($text)
/**
* Set the message pushtype.
*
* @param string $pushtype
* @param string $pushtype
*
* @return $this
*/
public function pushtype($pushtype)
Expand All @@ -70,7 +72,8 @@ public function pushtype($pushtype)
/**
* Set the message delay.
*
* @param \Carbon\Carbon $delay
* @param \Carbon\Carbon $delay
*
* @return $this
*/
public function delay($delay)
Expand All @@ -87,7 +90,8 @@ public function delay($delay)
/**
* Set the message sender.
*
* @param string $sender
* @param string $sender
*
* @return $this
*/
public function sender($sender)
Expand All @@ -100,7 +104,8 @@ public function sender($sender)
/**
* Set the message gsmsmsid.
*
* @param string $gsmsmsid
* @param string $gsmsmsid
*
* @return $this
*/
public function gsmsmsid($gsmsmsid)
Expand All @@ -109,4 +114,4 @@ public function gsmsmsid($gsmsmsid)

return $this;
}
}
}
8 changes: 4 additions & 4 deletions src/SmsFactorChannelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Xefi\SmsFactor;

use Illuminate\Notifications\ChannelManager;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\ServiceProvider;
use Xefi\SmsFactor\Channels\SmsFactorSmsChannel;
use Illuminate\Support\Facades\Notification;
use Illuminate\Notifications\ChannelManager;

class SmsFactorChannelServiceProvider extends ServiceProvider
{
Expand All @@ -16,7 +16,7 @@ class SmsFactorChannelServiceProvider extends ServiceProvider
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/sms-factor.php', 'sms-factor');
$this->mergeConfigFrom(__DIR__.'/../config/sms-factor.php', 'sms-factor');

Notification::resolved(function (ChannelManager $service) {
$service->extend('sms-factor', function ($app) {
Expand All @@ -40,4 +40,4 @@ public function boot()
], 'sms-factor');
}
}
}
}
63 changes: 31 additions & 32 deletions tests/Unit/Channels/SmsFactorSmsChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use SMSFactor\SMSFactor;
use Xefi\SmsFactor\Channels\SmsFactorSmsChannel;
use Xefi\SmsFactor\Messages\SmsFactorMessage;
use Xefi\SmsFactor\SmsFactorChannelServiceProvider;

class SmsFactorSmsChannelTest extends TestCase
{
Expand All @@ -24,20 +23,20 @@ protected function setUp(): void

public function testSmsIsSentViaSmsFactor()
{
$notification = new NotificationSmsFactorSmsChannelTestNotification;
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable;
$notification = new NotificationSmsFactorSmsChannelTestNotification();
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable();

$channel = new SmsFactorSmsChannel();

$this->mock('alias:'.Message::class, function (MockInterface $mock) {
$mock->shouldReceive('send')
->with(
[
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'pushtype' => null,
'sender' => null,
'sender' => null,
'gsmsmsid' => null,
]
)
Expand All @@ -49,20 +48,20 @@ public function testSmsIsSentViaSmsFactor()

public function testSmsIsSentViaSmsFactorWithCustomSender()
{
$notification = new NotificationSmsFactorSmsChannelTestCustomSenderNotification;
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable;
$notification = new NotificationSmsFactorSmsChannelTestCustomSenderNotification();
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable();

$channel = new SmsFactorSmsChannel();

$this->mock('alias:'.Message::class, function (MockInterface $mock) {
$mock->shouldReceive('send')
->with(
[
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'pushtype' => null,
'sender' => '12345',
'sender' => '12345',
'gsmsmsid' => null,
]
)
Expand All @@ -74,20 +73,20 @@ public function testSmsIsSentViaSmsFactorWithCustomSender()

public function testSmsIsSentViaSmsFactorWithCustomDelay()
{
$notification = new NotificationSmsFactorSmsChannelTestCustomDelayNotification;
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable;
$notification = new NotificationSmsFactorSmsChannelTestCustomDelayNotification();
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable();

$channel = new SmsFactorSmsChannel();

$this->mock('alias:'.Message::class, function (MockInterface $mock) {
$mock->shouldReceive('send')
->with(
[
'to' => '5555555555',
'text' => 'this is my message',
'delay' => Carbon::create(2024, 01, 01)->format('Y-m-d H:i:s'),
'to' => '5555555555',
'text' => 'this is my message',
'delay' => Carbon::create(2024, 01, 01)->format('Y-m-d H:i:s'),
'pushtype' => null,
'sender' => null,
'sender' => null,
'gsmsmsid' => null,
]
)
Expand All @@ -99,20 +98,20 @@ public function testSmsIsSentViaSmsFactorWithCustomDelay()

public function testSmsIsSentViaSmsFactorWithCustomPushType()
{
$notification = new NotificationSmsFactorSmsChannelTestCustomPushTypeNotification;
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable;
$notification = new NotificationSmsFactorSmsChannelTestCustomPushTypeNotification();
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable();

$channel = new SmsFactorSmsChannel();

$this->mock('alias:'.Message::class, function (MockInterface $mock) {
$mock->shouldReceive('send')
->with(
[
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'pushtype' => 'alert',
'sender' => null,
'sender' => null,
'gsmsmsid' => null,
]
)
Expand All @@ -124,20 +123,20 @@ public function testSmsIsSentViaSmsFactorWithCustomPushType()

public function testSmsIsSentViaSmsFactorWithCustomGsmsmsid()
{
$notification = new NotificationSmsFactorSmsChannelTestCustomGsmsmsidNotification;
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable;
$notification = new NotificationSmsFactorSmsChannelTestCustomGsmsmsidNotification();
$notifiable = new NotificationSmsFactorSmsChannelTestNotifiable();

$channel = new SmsFactorSmsChannel();

$this->mock('alias:'.Message::class, function (MockInterface $mock) {
$mock->shouldReceive('send')
->with(
[
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'to' => '5555555555',
'text' => 'this is my message',
'delay' => null,
'pushtype' => null,
'sender' => null,
'sender' => null,
'gsmsmsid' => 'my-custom-id',
]
)
Expand Down Expand Up @@ -198,4 +197,4 @@ public function routeNotificationForSmsFactor($notification)
{
return $this->phone_number;
}
}
}

0 comments on commit 22f3e99

Please sign in to comment.