Skip to content

Commit

Permalink
Add tests for make:job command
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidesu committed Feb 26, 2019
1 parent 7b47834 commit c694724
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/Console/Generators/CommandMakeJobTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Caffeinated\Modules\Tests\Commands\Generators;

use Caffeinated\Modules\Tests\BaseTestCase;
use Spatie\Snapshots\MatchesSnapshots;

class CommandMakeJobTest extends BaseTestCase
{
use MatchesSnapshots;

protected $finder;

public function setUp(): void
{
parent::setUp();

$this->finder = $this->app['files'];

$this->artisan('make:module', ['slug' => 'jobs', '--quick' => 'quick']);
}

/** @test */
public function it_can_generate_a_new_job_with_default_module_namespace()
{
$this->artisan('make:module:job', ['slug' => 'jobs', 'name' => 'DefaultJob']);

$file = $this->finder->get(module_path('jobs').'/Jobs/DefaultJob.php');

$this->assertMatchesSnapshot($file);
}

/** @test */
public function it_can_generate_a_new_job_with_custom_module_namespace()
{
$this->app['config']->set("modules.locations.$this->default.namespace", 'App\\CustomJobsNamespace\\');

$this->artisan('make:module:job', ['slug' => 'jobs', 'name' => 'CustomJob']);

$file = $this->finder->get(module_path('jobs').'/Jobs/CustomJob.php');

$this->assertMatchesSnapshot($file);
}

public function tearDown(): void
{
$this->finder->deleteDirectory(module_path('jobs'));

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php return '<?php
namespace App\\CustomJobsNamespace\\Jobs\\Jobs;
use Illuminate\\Bus\\Queueable;
use Illuminate\\Queue\\SerializesModels;
use Illuminate\\Queue\\InteractsWithQueue;
use Illuminate\\Contracts\\Queue\\ShouldQueue;
use Illuminate\\Foundation\\Bus\\Dispatchable;
class CustomJob 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()
{
//
}
}
';
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php return '<?php
namespace App\\Modules\\Jobs\\Jobs;
use Illuminate\\Bus\\Queueable;
use Illuminate\\Queue\\SerializesModels;
use Illuminate\\Queue\\InteractsWithQueue;
use Illuminate\\Contracts\\Queue\\ShouldQueue;
use Illuminate\\Foundation\\Bus\\Dispatchable;
class DefaultJob 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()
{
//
}
}
';

0 comments on commit c694724

Please sign in to comment.