-
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.
Adds command and stub for generating a Blitz load test in the correct…
… place
- Loading branch information
Showing
2 changed files
with
65 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,52 @@ | ||
<?php | ||
|
||
namespace CraigPaul\Blitz\Console\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
use Illuminate\Support\Str; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
|
||
#[AsCommand('blitz:make', 'Create a new test class')] | ||
class TestMakeCommand extends GeneratorCommand | ||
{ | ||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Test'; | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/test.stub'; | ||
} | ||
|
||
/** | ||
* Get the destination class path. | ||
* | ||
* @param string $name | ||
* | ||
* @return string | ||
*/ | ||
protected function getPath($name) | ||
{ | ||
$name = Str::replaceFirst($this->rootNamespace(), '', $name); | ||
|
||
return $this->getLaravel()->basePath('tests/Blitz').str_replace('\\', '/', $name).'.php'; | ||
} | ||
|
||
/** | ||
* Get the root namespace for the class. | ||
* | ||
* @return string | ||
*/ | ||
protected function rootNamespace() | ||
{ | ||
return 'Tests\\Blitz'; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use CraigPaul\Blitz\Testing\TestCase; | ||
|
||
class {{ class }} extends TestCase | ||
{ | ||
public function handle(): void | ||
{ | ||
// | ||
} | ||
} |