Skip to content

Commit

Permalink
Test a job is dispatchable
Browse files Browse the repository at this point in the history
  • Loading branch information
unclexo committed Jan 27, 2023
1 parent c1917de commit 6de30ac
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/Jobs/ImageUploadAndResizingJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ImageUploadAndResizingJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
}
}
25 changes: 25 additions & 0 deletions tests/Feature/JobTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Tests\Feature;

use App\Jobs\ImageUploadAndResizingJob;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class JobTest extends TestCase
{
/** @test */
public function a_job_is_dispatchable()
{
$job = new \ReflectionClass(ImageUploadAndResizingJob::class);

$this->assertTrue(in_array(Dispatchable::class, $job->getTraitNames()));

$this->assertTrue(method_exists(
app(ImageUploadAndResizingJob::class),
'handle'
));
}
}

0 comments on commit 6de30ac

Please sign in to comment.