@@ -104,6 +104,29 @@ public function testItCanSendQueuedMultiChannelNotificationsThroughDifferentMidd
104
104
105
105
$ sender ->send ($ notifiable , new DummyMultiChannelNotificationWithConditionalMiddlware );
106
106
}
107
+
108
+ public function testItCanSendQueuedWithViaConnectionsNotifications ()
109
+ {
110
+ $ notifiable = new AnonymousNotifiable ;
111
+ $ manager = m::mock (ChannelManager::class);
112
+ $ bus = m::mock (BusDispatcher::class);
113
+ $ bus ->shouldReceive ('dispatch ' )
114
+ ->once ()
115
+ ->withArgs (function ($ job ) {
116
+ return $ job ->connection === 'sync ' && $ job ->channels === ['database ' ];
117
+ });
118
+ $ bus ->shouldReceive ('dispatch ' )
119
+ ->once ()
120
+ ->withArgs (function ($ job ) {
121
+ return $ job ->connection === null && $ job ->channels === ['mail ' ];
122
+ });
123
+
124
+ $ events = m::mock (EventDispatcher::class);
125
+
126
+ $ sender = new NotificationSender ($ manager , $ bus , $ events );
127
+
128
+ $ sender ->send ($ notifiable , new DummyNotificationWithViaConnections );
129
+ }
107
130
}
108
131
109
132
class DummyQueuedNotificationWithStringVia extends Notification implements ShouldQueue
@@ -154,6 +177,23 @@ public function via($notifiable)
154
177
}
155
178
}
156
179
180
+ class DummyNotificationWithViaConnections extends Notification implements ShouldQueue
181
+ {
182
+ use Queueable;
183
+
184
+ public function via ($ notifiable )
185
+ {
186
+ return ['mail ' , 'database ' ];
187
+ }
188
+
189
+ public function viaConnections ()
190
+ {
191
+ return [
192
+ 'database ' => 'sync ' ,
193
+ ];
194
+ }
195
+ }
196
+
157
197
class DummyNotificationWithMiddleware extends Notification implements ShouldQueue
158
198
{
159
199
use Queueable;
0 commit comments