Skip to content

Commit

Permalink
[8.x] Added new assertNothingDispatched method to BusFake (#39286)
Browse files Browse the repository at this point in the history
* Added new assertNothingDispatched method to BusFake

* Fix broken test
  • Loading branch information
carlalexander authored Oct 21, 2021
1 parent 5478822 commit d11799c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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 @@ -135,6 +135,16 @@ public function assertNotDispatched($command, $callback = null)
);
}

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

/**
* Assert if a job was explicitly dispatched synchronously based on 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 @@ -362,6 +362,20 @@ public function testAssertNotDispatchedSyncClosure()
}
}

public function testAssertNothingDispatched()
{
$this->fake->assertNothingDispatched();

$this->fake->dispatch(new BusJobStub);

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

public function testAssertDispatchedWithIgnoreClass()
{
$dispatcher = m::mock(QueueingDispatcher::class);
Expand Down

0 comments on commit d11799c

Please sign in to comment.