Skip to content

Instantly share code, notes, and snippets.

@aliuwahab
Last active March 11, 2019 09:12
Show Gist options
  • Save aliuwahab/13ea74f0600504e483ff3b24c5cabc20 to your computer and use it in GitHub Desktop.
Save aliuwahab/13ea74f0600504e483ff3b24c5cabc20 to your computer and use it in GitHub Desktop.
ExampleTest
<?php
namespace Tests\Feature;
use App\Jobs\ExampleJob;
use App\User;
use Illuminate\Support\Facades\Bus;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
use RefreshDatabase;
/** @test */
public function bus_fake_test()
{
$this->withoutExceptionHandling();
Bus::fake();
$user = factory(User::class)->create();
$this->get('/example/job');
Bus::assertDispatched(ExampleJob::class, function ($job) use ($user) {
return $job->user->id === $user->id;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment