diff --git a/src/Illuminate/Support/Testing/Fakes/BusFake.php b/src/Illuminate/Support/Testing/Fakes/BusFake.php index 89250efef79..73b05ff6e56 100644 --- a/src/Illuminate/Support/Testing/Fakes/BusFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BusFake.php @@ -361,6 +361,16 @@ public function assertChained(array $expectedChain) $this->assertDispatchedWithChainOfObjects($command, $expectedChain, $callback); } + /** + * Assert no chained jobs was dispatched. + * + * @return void + */ + public function assertNothingChained() + { + $this->assertNothingDispatched(); + } + /** * Reset the chain properties to their default values on the job. * @@ -504,6 +514,17 @@ public function assertNothingBatched() PHPUnit::assertEmpty($this->batches, "The following batched jobs were dispatched unexpectedly:\n\n- $jobNames\n"); } + /** + * Assert that no jobs were dispatched, chained, or batched. + * + * @return void + */ + public function assertNothingPlaced() + { + $this->assertNothingDispatched(); + $this->assertNothingBatched(); + } + /** * Get all of the jobs matching a truth-test callback. * diff --git a/tests/Support/SupportTestingBusFakeTest.php b/tests/Support/SupportTestingBusFakeTest.php index c6705137af2..68b471c780d 100644 --- a/tests/Support/SupportTestingBusFakeTest.php +++ b/tests/Support/SupportTestingBusFakeTest.php @@ -548,6 +548,20 @@ public function testAssertChained() Container::setInstance(null); } + public function testAssertNothingChained() + { + $this->fake->assertNothingChained(); + } + + public function testAssertNothingChainedFails() + { + $this->fake->chain([new ChainedJobStub])->dispatch(); + + $this->expectException(ExpectationFailedException::class); + + $this->fake->assertNothingChained(); + } + public function testAssertDispatchedWithIgnoreClass() { $dispatcher = m::mock(QueueingDispatcher::class); @@ -661,6 +675,47 @@ public function testAssertNothingBatched() } } + public function testAssertEmptyPasses() + { + $this->fake->assertNothingPlaced(); + } + + public function testAssertEmptyFailedWhenJobBatched() + { + $this->fake->batch([new BusJobStub])->dispatch(); + + $this->expectException(ExpectationFailedException::class); + + $this->fake->assertNothingPlaced(); + } + + public function testAssertEmptyFailedWhenJobDispatched() + { + $this->fake->dispatch(new BusJobStub); + + $this->expectException(ExpectationFailedException::class); + + $this->fake->assertNothingPlaced(); + } + + public function testAssertEmptyFailedWhenJobChained() + { + $this->fake->chain([new ChainedJobStub])->dispatch(); + + $this->expectException(ExpectationFailedException::class); + + $this->fake->assertNothingPlaced(); + } + + public function testAssertEmptyFailedWhenJobDispatchedNow() + { + $this->fake->dispatchNow(new BusJobStub); + + $this->expectException(ExpectationFailedException::class); + + $this->fake->assertNothingPlaced(); + } + public function testFindBatch() { $this->assertNull($this->fake->findBatch('non-existent-batch'));