Created
May 24, 2018 16:34
-
-
Save ar-android/d62151c7070759833748f38edc8565b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Support\Str; | |
use Illuminate\Console\GeneratorCommand; | |
class TestMakeCommand extends GeneratorCommand | |
{ | |
/** | |
* The console command name. | |
* | |
* @var string | |
*/ | |
protected $signature = 'make:test {name : The name of the class}'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Create a new test class'; | |
/** | |
* 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 base_path('tests').str_replace('\\', '/', $name).'.php'; | |
} | |
/** | |
* Get the default namespace for the class. | |
* | |
* @param string $rootNamespace | |
* @return string | |
*/ | |
protected function getDefaultNamespace($rootNamespace) | |
{ | |
return $rootNamespace; | |
} | |
/** | |
* Get the root namespace for the class. | |
* | |
* @return string | |
*/ | |
protected function rootNamespace() | |
{ | |
return "Test"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment