@@ -127,15 +127,21 @@ public function assertDispatched($command, $callback = null)
127
127
/**
128
128
* Assert if a job was pushed a number of times.
129
129
*
130
- * @param string $command
130
+ * @param string|\Closure $command
131
131
* @param int $times
132
132
* @return void
133
133
*/
134
134
public function assertDispatchedTimes ($ command , $ times = 1 )
135
135
{
136
- $ count = $ this ->dispatched ($ command )->count () +
137
- $ this ->dispatchedAfterResponse ($ command )->count () +
138
- $ this ->dispatchedSync ($ command )->count ();
136
+ $ callback = null ;
137
+
138
+ if ($ command instanceof Closure) {
139
+ [$ command , $ callback ] = [$ this ->firstClosureParameterType ($ command ), $ command ];
140
+ }
141
+
142
+ $ count = $ this ->dispatched ($ command , $ callback )->count () +
143
+ $ this ->dispatchedAfterResponse ($ command , $ callback )->count () +
144
+ $ this ->dispatchedSync ($ command , $ callback )->count ();
139
145
140
146
PHPUnit::assertSame (
141
147
$ times , $ count ,
@@ -200,13 +206,19 @@ public function assertDispatchedSync($command, $callback = null)
200
206
/**
201
207
* Assert if a job was pushed synchronously a number of times.
202
208
*
203
- * @param string $command
209
+ * @param string|\Closure $command
204
210
* @param int $times
205
211
* @return void
206
212
*/
207
213
public function assertDispatchedSyncTimes ($ command , $ times = 1 )
208
214
{
209
- $ count = $ this ->dispatchedSync ($ command )->count ();
215
+ $ callback = null ;
216
+
217
+ if ($ command instanceof Closure) {
218
+ [$ command , $ callback ] = [$ this ->firstClosureParameterType ($ command ), $ command ];
219
+ }
220
+
221
+ $ count = $ this ->dispatchedSync ($ command , $ callback )->count ();
210
222
211
223
PHPUnit::assertSame (
212
224
$ times , $ count ,
@@ -259,13 +271,19 @@ public function assertDispatchedAfterResponse($command, $callback = null)
259
271
/**
260
272
* Assert if a job was pushed after the response was sent a number of times.
261
273
*
262
- * @param string $command
274
+ * @param string|\Closure $command
263
275
* @param int $times
264
276
* @return void
265
277
*/
266
278
public function assertDispatchedAfterResponseTimes ($ command , $ times = 1 )
267
279
{
268
- $ count = $ this ->dispatchedAfterResponse ($ command )->count ();
280
+ $ callback = null ;
281
+
282
+ if ($ command instanceof Closure) {
283
+ [$ command , $ callback ] = [$ this ->firstClosureParameterType ($ command ), $ command ];
284
+ }
285
+
286
+ $ count = $ this ->dispatchedAfterResponse ($ command , $ callback )->count ();
269
287
270
288
PHPUnit::assertSame (
271
289
$ times , $ count ,
0 commit comments