-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27710 from driesvints/fix-notification-sender
[5.8] Fix a bug with string via in queued notifications
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Notifications; | ||
|
||
use Mockery as m; | ||
use Illuminate\Bus\Queueable; | ||
use PHPUnit\Framework\TestCase; | ||
use Illuminate\Notifications\Notifiable; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\ChannelManager; | ||
use Illuminate\Notifications\NotificationSender; | ||
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; | ||
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; | ||
|
||
class NotificationSenderTest extends TestCase | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
m::close(); | ||
} | ||
|
||
public function test_it_can_send_queued_notifications_with_a_string_via() | ||
{ | ||
$notifiable = m::mock(Notifiable::class); | ||
$manager = m::mock(ChannelManager::class); | ||
$bus = m::mock(BusDispatcher::class); | ||
$bus->shouldReceive('dispatch'); | ||
$events = m::mock(EventDispatcher::class); | ||
|
||
$sender = new NotificationSender($manager, $bus, $events); | ||
|
||
$sender->send($notifiable, new DummyQueuedNotificationWithStringVia()); | ||
} | ||
} | ||
|
||
class DummyQueuedNotificationWithStringVia extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* Get the notification channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array|string | ||
* @return array|string | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return 'mail'; | ||
} | ||
} |