Skip to content

Commit

Permalink
update NotificationFake.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Xurshudyan committed Jan 14, 2024
1 parent d14cb38 commit 8340930
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Illuminate/Support/Testing/Fakes/NotificationFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use Illuminate\Contracts\Notifications\Dispatcher as NotificationDispatcher;
use Illuminate\Contracts\Notifications\Factory as NotificationFactory;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -454,6 +455,10 @@ protected function queuedNotificationsFor($notifiable, $notification)
*/
public function send($notifiables, $notification)
{
if ($notification instanceof ShouldQueue) {
return $this->queue($notifiables, $notification);
}

$this->sendNow($notifiables, $notification);
}

Expand Down Expand Up @@ -507,10 +512,9 @@ public function sendNow($notifiables, $notification, array $channels = null)
*
* @param \Illuminate\Support\Collection|array|mixed $notifiables
* @param mixed $notification
* @param array|null $channels
* @return void
*/
protected function queue($notifiables, $notification, array $channels = null)
protected function queue($notifiables, $notification)
{
if (! $notifiables instanceof Collection && ! is_array($notifiables)) {
$notifiables = [$notifiables];
Expand All @@ -521,22 +525,15 @@ protected function queue($notifiables, $notification, array $channels = null)
$notification->id = Str::uuid()->toString();
}

$notifiableChannels = $channels ?: $notification->via($notifiable);

if (method_exists($notification, 'shouldSend')) {
$notifiableChannels = array_filter(
$notifiableChannels,
fn ($channel) => $notification->shouldSend($notifiable, $channel) !== false
);
}

if (empty($notifiableChannels)) {
continue;
}

$this->queuedNotifications[get_class($notifiable)][$notifiable->getKey()][get_class($notification)][] = [
'notification' => $notification,
'channels' => $notifiableChannels,
'notifiable' => $notifiable,
'locale' => $notification->locale ?? $this->locale ?? value(function () use ($notifiable) {
if ($notifiable instanceof HasLocalePreference) {
Expand Down

0 comments on commit 8340930

Please sign in to comment.