Skip to content

Commit e6614cc

Browse files
[12.x] Add the assertClosureNotPushed method (#10648)
* Add the assertClosureNotPushed method and an example, revise some wording. * Update queues.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent b6f3de3 commit e6614cc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

queues.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,9 +2488,12 @@ test('orders can be shipped', function () {
24882488
// Assert a job was not pushed...
24892489
Queue::assertNotPushed(AnotherJob::class);
24902490

2491-
// Assert that a Closure was pushed to the queue...
2491+
// Assert that a closure was pushed to the queue...
24922492
Queue::assertClosurePushed();
24932493

2494+
// Assert that a closure was not pushed...
2495+
Queue::assertClosureNotPushed();
2496+
24942497
// Assert the total number of jobs that were pushed...
24952498
Queue::assertCount(3);
24962499
});
@@ -2527,21 +2530,30 @@ class ExampleTest extends TestCase
25272530
// Assert a job was not pushed...
25282531
Queue::assertNotPushed(AnotherJob::class);
25292532

2530-
// Assert that a Closure was pushed to the queue...
2533+
// Assert that a closure was pushed to the queue...
25312534
Queue::assertClosurePushed();
25322535

2536+
// Assert that a closure was not pushed...
2537+
Queue::assertClosureNotPushed();
2538+
25332539
// Assert the total number of jobs that were pushed...
25342540
Queue::assertCount(3);
25352541
}
25362542
}
25372543
```
25382544

2539-
You may pass a closure to the `assertPushed` or `assertNotPushed` methods in order to assert that a job was pushed that passes a given "truth test". If at least one job was pushed that passes the given truth test then the assertion will be successful:
2545+
You may pass a closure to the `assertPushed`, `assertNotPushed`, `assertClosurePushed`, or `assertClosureNotPushed` methods in order to assert that a job was pushed that passes a given "truth test". If at least one job was pushed that passes the given truth test then the assertion will be successful:
25402546

25412547
```php
2548+
use Illuminate\Queue\CallQueuedClosure;
2549+
25422550
Queue::assertPushed(function (ShipOrder $job) use ($order) {
25432551
return $job->order->id === $order->id;
25442552
});
2553+
2554+
Queue::assertClosurePushed(function (CallQueuedClosure $job) {
2555+
return $job->name === 'validate-order';
2556+
});
25452557
```
25462558

25472559
<a name="faking-a-subset-of-jobs"></a>

0 commit comments

Comments
 (0)