File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public function __construct(OneSignalClient $oneSignal)
2929 public function send ($ notifiable , Notification $ notification )
3030 {
3131 if (! $ userIds = $ notifiable ->routeNotificationFor ('OneSignal ' )) {
32- return ;
32+ return null ;
3333 }
3434
3535 $ payload = $ notification ->toOneSignal ($ notifiable )->toArray ();
Original file line number Diff line number Diff line change 88use Berkayk \OneSignal \OneSignalClient ;
99use NotificationChannels \OneSignal \OneSignalChannel ;
1010use NotificationChannels \OneSignal \Exceptions \CouldNotSendNotification ;
11+ use Psr \Http \Message \ResponseInterface ;
1112
1213class ChannelTest extends TestCase
1314{
@@ -52,7 +53,9 @@ public function it_can_send_a_notification()
5253 ])
5354 ->andReturn ($ response );
5455
55- $ this ->channel ->send (new Notifiable (), new TestNotification ());
56+ $ channel_response = $ this ->channel ->send (new Notifiable (), new TestNotification ());
57+
58+ $ this ->assertInstanceOf (ResponseInterface::class, $ channel_response );
5659 }
5760
5861 /** @test */
@@ -104,6 +107,18 @@ public function it_can_send_a_notification_with_email()
104107 ])
105108 ->andReturn ($ response );
106109
107- $ this ->channel ->send (new NotifiableEmail (), new TestNotification ());
110+ $ channel_response = $ this ->channel ->send (new NotifiableEmail (), new TestNotification ());
111+
112+ $ this ->assertInstanceOf (ResponseInterface::class, $ channel_response );
113+ }
114+
115+ /** @test */
116+ public function it_sends_nothing_and_returns_null_when_player_id_empty ()
117+ {
118+ $ this ->oneSignal ->shouldReceive ('sendNotificationCustom ' )
119+ ->never ();
120+
121+ $ channel_response = $ this ->channel ->send (new EmptyNotifiable (), new TestNotification ());
122+ $ this ->assertNull ($ channel_response );
108123 }
109124}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace NotificationChannels \OneSignal \Test ;
4+
5+ class EmptyNotifiable
6+ {
7+ use \Illuminate \Notifications \Notifiable;
8+
9+ /**
10+ * @return int
11+ */
12+ public function routeNotificationForOneSignal ()
13+ {
14+ return '' ;
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments