Skip to content

Commit

Permalink
Merge pull request #102 from hansnn/fix-failed-event-channel-type
Browse files Browse the repository at this point in the history
Fix channel type of NotificationFailed events
  • Loading branch information
dwightwatson committed Jun 9, 2020
2 parents 8be4164 + edb3330 commit e99ad69
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ApnChannel.php
Expand Up @@ -96,7 +96,7 @@ protected function dispatchEvents($notifiable, $notification, array $responses)
continue;
}

$event = new NotificationFailed($notifiable, $notification, $this, [
$event = new NotificationFailed($notifiable, $notification, static::class, [
'id' => $response->getApnsId(),
'token' => $response->getDeviceToken(),
'error' => $response->getErrorReason(),
Expand Down
19 changes: 19 additions & 0 deletions tests/ApnChannelTest.php
Expand Up @@ -62,4 +62,23 @@ public function it_dispatches_events_for_failed_notifications()

$this->channel->send(new TestNotifiable, new TestNotification);
}

/** @test */
public function it_dispatches_failed_notification_events_with_correct_channel()
{
$this->events->shouldReceive('dispatch')
->withArgs(function (NotificationFailed $notificationFailed) {
return $notificationFailed->channel === ApnChannel::class;
});

$this->client->shouldReceive('addNotification');
$this->client->shouldReceive('push')
->once()
->andReturn([
new Response(200, 'headers', 'body'),
new Response(400, 'headers', 'body'),
]);

$this->channel->send(new TestNotifiable, new TestNotification);
}
}

0 comments on commit e99ad69

Please sign in to comment.