Skip to content

Commit c48ad5d

Browse files
Add missing method tag and common assertion (#44056)
* Add missing method tag * Add common assertion
1 parent 59cf9c7 commit c48ad5d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Illuminate/Support/Facades/Bus.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
* @method static void assertDispatched(string|\Closure $command, callable|int $callback = null)
2121
* @method static void assertDispatchedTimes(string $command, int $times = 1)
2222
* @method static void assertNotDispatched(string|\Closure $command, callable|int $callback = null)
23+
* @method static void assertNothingDispatched()
2324
* @method static void assertDispatchedAfterResponse(string|\Closure $command, callable|int $callback = null)
2425
* @method static void assertDispatchedAfterResponseTimes(string $command, int $times = 1)
2526
* @method static void assertNotDispatchedAfterResponse(string|\Closure $command, callable $callback = null)
2627
* @method static void assertBatched(callable $callback)
2728
* @method static void assertBatchCount(int $count)
29+
* @method static void assertNothingBatched()
2830
* @method static void assertChained(array $expectedChain)
2931
* @method static void assertDispatchedSync(string|\Closure $command, callable $callback = null)
3032
* @method static void assertDispatchedSyncTimes(string $command, int $times = 1)

src/Illuminate/Support/Testing/Fakes/BusFake.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,16 @@ public function assertBatchCount($count)
422422
);
423423
}
424424

425+
/**
426+
* Assert that no batched jobs were dispatched.
427+
*
428+
* @return void
429+
*/
430+
public function assertNothingBatched()
431+
{
432+
PHPUnit::assertEmpty($this->batches, 'Batched jobs were dispatched unexpectedly.');
433+
}
434+
425435
/**
426436
* Get all of the jobs matching a truth-test callback.
427437
*

tests/Support/SupportTestingBusFakeTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,20 @@ function ($command) {
454454
return $job->id === 1;
455455
});
456456
}
457+
458+
public function testAssertNothingBatched()
459+
{
460+
$this->fake->assertNothingBatched();
461+
462+
$this->fake->batch([])->dispatch();
463+
464+
try {
465+
$this->fake->assertNothingBatched();
466+
$this->fail();
467+
} catch (ExpectationFailedException $e) {
468+
$this->assertThat($e, new ExceptionMessage('Batched jobs were dispatched unexpectedly.'));
469+
}
470+
}
457471
}
458472

459473
class BusJobStub

0 commit comments

Comments
 (0)