Skip to content

Commit d11799c

Browse files
[8.x] Added new assertNothingDispatched method to BusFake (#39286)
* Added new assertNothingDispatched method to BusFake * Fix broken test
1 parent 5478822 commit d11799c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ public function assertNotDispatched($command, $callback = null)
135135
);
136136
}
137137

138+
/**
139+
* Assert that no jobs were dispatched.
140+
*
141+
* @return void
142+
*/
143+
public function assertNothingDispatched()
144+
{
145+
PHPUnit::assertEmpty($this->commands, 'Jobs were dispatched unexpectedly.');
146+
}
147+
138148
/**
139149
* Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
140150
*

tests/Support/SupportTestingBusFakeTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,20 @@ public function testAssertNotDispatchedSyncClosure()
362362
}
363363
}
364364

365+
public function testAssertNothingDispatched()
366+
{
367+
$this->fake->assertNothingDispatched();
368+
369+
$this->fake->dispatch(new BusJobStub);
370+
371+
try {
372+
$this->fake->assertNothingDispatched();
373+
$this->fail();
374+
} catch (ExpectationFailedException $e) {
375+
$this->assertThat($e, new ExceptionMessage('Jobs were dispatched unexpectedly.'));
376+
}
377+
}
378+
365379
public function testAssertDispatchedWithIgnoreClass()
366380
{
367381
$dispatcher = m::mock(QueueingDispatcher::class);

0 commit comments

Comments
 (0)