forked from caffeinated/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...shots__/CommandMakeJobTest__it_can_generate_a_new_job_with_custom_module_namespace__1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
{ | ||
// | ||
} | ||
} | ||
'; |
35 changes: 35 additions & 0 deletions
35
...hots__/CommandMakeJobTest__it_can_generate_a_new_job_with_default_module_namespace__1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
{ | ||
// | ||
} | ||
} | ||
'; |