Skip to content

Commit

Permalink
Add missing method tag and common assertion (#44056)
Browse files Browse the repository at this point in the history
* Add missing method tag

* Add common assertion
  • Loading branch information
jasonmccreary authored Sep 9, 2022
1 parent 59cf9c7 commit c48ad5d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Illuminate/Support/Facades/Bus.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
* @method static void assertDispatched(string|\Closure $command, callable|int $callback = null)
* @method static void assertDispatchedTimes(string $command, int $times = 1)
* @method static void assertNotDispatched(string|\Closure $command, callable|int $callback = null)
* @method static void assertNothingDispatched()
* @method static void assertDispatchedAfterResponse(string|\Closure $command, callable|int $callback = null)
* @method static void assertDispatchedAfterResponseTimes(string $command, int $times = 1)
* @method static void assertNotDispatchedAfterResponse(string|\Closure $command, callable $callback = null)
* @method static void assertBatched(callable $callback)
* @method static void assertBatchCount(int $count)
* @method static void assertNothingBatched()
* @method static void assertChained(array $expectedChain)
* @method static void assertDispatchedSync(string|\Closure $command, callable $callback = null)
* @method static void assertDispatchedSyncTimes(string $command, int $times = 1)
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Support/Testing/Fakes/BusFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ public function assertBatchCount($count)
);
}

/**
* Assert that no batched jobs were dispatched.
*
* @return void
*/
public function assertNothingBatched()
{
PHPUnit::assertEmpty($this->batches, 'Batched jobs were dispatched unexpectedly.');
}

/**
* Get all of the jobs matching a truth-test callback.
*
Expand Down
14 changes: 14 additions & 0 deletions tests/Support/SupportTestingBusFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,20 @@ function ($command) {
return $job->id === 1;
});
}

public function testAssertNothingBatched()
{
$this->fake->assertNothingBatched();

$this->fake->batch([])->dispatch();

try {
$this->fake->assertNothingBatched();
$this->fail();
} catch (ExpectationFailedException $e) {
$this->assertThat($e, new ExceptionMessage('Batched jobs were dispatched unexpectedly.'));
}
}
}

class BusJobStub
Expand Down

0 comments on commit c48ad5d

Please sign in to comment.