Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
build
composer.phar
composer.lock
.idea
.idea
.phpunit.result.cache
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"require": {
"php": "^8.0",
"alymosul/exponent-server-sdk-php": "1.3.*",
"laravel/framework": "^9.0"
"laravel/framework": "^9.0|^10.0"
},
"require-dev": {
"mockery/mockery": "^1.5.0",
"phpunit/phpunit": "^9.0",
"orchestra/testbench": "^7.1.0"
"orchestra/testbench": "^7.1.0|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/ExpoChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Notifications\Events\NotificationFailed;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;
use NotificationChannels\ExpoPushNotifications\Exceptions\CouldNotSendNotification;

class ExpoChannel
Expand Down Expand Up @@ -47,7 +48,7 @@ public function send($notifiable, Notification $notification)
$interest = $notifiable->routeNotificationFor('ExpoPushNotifications')
?: $this->interestName($notifiable);

$interests = [$interest];
$interests = Arr::wrap($interest);

try {
$this->expo->notify(
Expand Down
18 changes: 18 additions & 0 deletions tests/ChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ public function itCanSendANotification()
$this->channel->send($this->notifiable, $this->notification);
}

/** @test */
public function itCanSendANNotificationToMultipleInterests()
{
$this->notifiable = Mockery::mock($this->notifiable);

$this->notifiable->shouldReceive('routeNotificationFor')
->with('ExpoPushNotifications')
->andReturn($interests = ['interest_1', 'interest_2']);

$message = $this->notification->toExpoPush($this->notifiable);

$data = $message->toArray();

$this->expo->shouldReceive('notify')->with($interests, $data, true)->andReturn([['status' => 'ok']]);

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

/** @test */
public function itFiresFailureEventOnFailure()
{
Expand Down