Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created May 24, 2018 16:34
Show Gist options
  • Save ar-android/d62151c7070759833748f38edc8565b2 to your computer and use it in GitHub Desktop.
Save ar-android/d62151c7070759833748f38edc8565b2 to your computer and use it in GitHub Desktop.
<?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