ExportOrdersJobTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Tests\Unit\Jobs;
  3. use App\Jobs\ExportOrdersJob;
  4. use Illuminate\Support\Facades\Bus;
  5. use Illuminate\Support\Facades\Queue;
  6. use Tests\TestCase;
  7. class ExportOrdersJobTest extends TestCase
  8. {
  9. public function test_job_can_be_dispatched(): void
  10. {
  11. Bus::fake();
  12. ExportOrdersJob::dispatch(collect([]), 1);
  13. Bus::assertDispatched(ExportOrdersJob::class);
  14. }
  15. public function test_job_dispatched_with_correct_user_id(): void
  16. {
  17. Bus::fake();
  18. ExportOrdersJob::dispatch(collect(['order1', 'order2']), 42);
  19. Bus::assertDispatched(ExportOrdersJob::class, function (ExportOrdersJob $job) {
  20. return true;
  21. });
  22. }
  23. public function test_job_is_queued_via_queue_fake(): void
  24. {
  25. Queue::fake();
  26. ExportOrdersJob::dispatch(collect([]), 1);
  27. Queue::assertPushed(ExportOrdersJob::class);
  28. }
  29. public function test_job_not_dispatched_without_dispatch_call(): void
  30. {
  31. Bus::fake();
  32. Bus::assertNotDispatched(ExportOrdersJob::class);
  33. }
  34. }