|
|
@@ -22,8 +22,7 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
|
|
|
||$this->option('controllers')) {
|
|
|
return $rootNamespace.'\Controllers';
|
|
|
}
|
|
|
- if ($this->option('services')
|
|
|
- ||$this->option('service')) {
|
|
|
+ if ($this->isForService()) {
|
|
|
return $rootNamespace.'\Services\\'
|
|
|
.$this->getServiceName()
|
|
|
;
|
|
|
@@ -35,9 +34,20 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected function isForService()
|
|
|
+ {
|
|
|
+ if ($this->option('services')
|
|
|
+ ||$this->option('service')) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
protected function getNameInput()
|
|
|
{
|
|
|
$input= trim($this->argument('name'));
|
|
|
+ if(!$this->isForService()){
|
|
|
+ return $input;
|
|
|
+ }
|
|
|
$inputs = explode(':', $input);
|
|
|
return $inputs[1]
|
|
|
?$this->getMethodName()
|
|
|
@@ -47,16 +57,22 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
|
|
|
protected function getServiceName()
|
|
|
{
|
|
|
$input= trim($this->argument('name'));
|
|
|
+ if(!$this->isForService()){
|
|
|
+ return $input;
|
|
|
+ }
|
|
|
return ucfirst(explode(':',$input)[0]);
|
|
|
}
|
|
|
protected function getModelName()
|
|
|
{
|
|
|
$input= trim($this->argument('name'));
|
|
|
+ if(!$this->isForService()){
|
|
|
+ return $input;
|
|
|
+ }
|
|
|
return str_replace('Service','',(explode(':',$input)[0]));
|
|
|
}
|
|
|
protected function getModelNamePlural()
|
|
|
{
|
|
|
- $modelName=preg_replace('/(s|x|ch|sh)$/','ses',lcfirst($this->getModelName()));
|
|
|
+ $modelName=preg_replace('/(s|x|ch|sh)$/','$1es',lcfirst($this->getModelName()));
|
|
|
$modelName=preg_replace('/y$/','ies',$modelName);
|
|
|
$modelName=preg_replace('/[cC]hild$/','children',$modelName);
|
|
|
if(preg_match('/[cC]hildren$/',$modelName)==0){
|
|
|
@@ -67,6 +83,9 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
|
|
|
protected function getMethodName()
|
|
|
{
|
|
|
$input= trim($this->argument('name'));
|
|
|
+ if(!$this->isForService()){
|
|
|
+ return $input;
|
|
|
+ }
|
|
|
return ucfirst(explode(':',$input)[1]).'Test';
|
|
|
}
|
|
|
|
|
|
@@ -92,7 +111,7 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
|
|
|
$stub = str_replace(['{{ serviceName }}', '{{serviceName}}'], $this->getServiceName(), $stub);
|
|
|
$stub = str_replace(['{{ modelName }}', '{{modelName}}'], $this->getModelName(), $stub);
|
|
|
$stub = str_replace(['{{ modelNameUc }}', '{{modelNameUc}}'], ucfirst($this->getModelName()), $stub);
|
|
|
- $stub = str_replace(['{{ modelNamePlural }}', '{{modelNamePlural}}'], ucfirst($this->getModelNamePlural()), $stub);
|
|
|
+ $stub = str_replace(['{{ modelNamePlural }}', '{{modelNamePlural}}'], lcfirst($this->getModelNamePlural()), $stub);
|
|
|
|
|
|
return str_replace(['DummyClass', '{{ class }}', '{{class}}'], $class, $stub);
|
|
|
}
|