Browse Source

Merge branch 'controller-name-convention'

tags/1.2.0
Nafies Luthfi 7 years ago
parent
commit
c8656f27b5
  1. 8
      src/Generators/ControllerGenerator.php
  2. 4
      src/Generators/FeatureTestGenerator.php
  3. 6
      src/Generators/RouteGenerator.php
  4. 2
      src/stubs/controllers/api.stub
  5. 2
      src/stubs/controllers/full.stub
  6. 2
      src/stubs/controllers/simple.stub
  7. 2
      src/stubs/routes/api.stub
  8. 2
      src/stubs/routes/web.stub
  9. 2
      src/stubs/testcases/feature/api.stub
  10. 2
      src/stubs/testcases/feature/full.stub
  11. 2
      src/stubs/testcases/feature/simple.stub
  12. 6
      tests/CommandOptions/TestsOnlyOptionsTest.php
  13. 20
      tests/CrudApiMakeCommandTest.php
  14. 18
      tests/CrudMakeCommandTest.php
  15. 18
      tests/CrudSimpleMakeCommandTest.php
  16. 6
      tests/Generators/Api/ApiControllerGeneratorTest.php
  17. 12
      tests/Generators/Api/ApiFeatureTestGeneratorTest.php
  18. 4
      tests/Generators/Api/RouteApiGeneratorTest.php
  19. 12
      tests/Generators/FeatureTestGeneratorTest.php
  20. 18
      tests/Generators/FullControllerGeneratorTest.php
  21. 4
      tests/Generators/RouteWebGeneratorTest.php
  22. 12
      tests/Generators/Simple/FeatureTestGeneratorTest.php
  23. 18
      tests/Generators/Simple/SimpleControllerGeneratorTest.php

8
src/Generators/ControllerGenerator.php

@ -12,7 +12,7 @@ class ControllerGenerator extends BaseGenerator
*/
public function generate(string $type = 'full')
{
$pluralModelName = $this->modelNames['plural_model_name'];
$modelName = $this->modelNames['model_name'];
$parentControllerDirectory = '';
if (!is_null($this->command->option('parent'))) {
$parentControllerDirectory = '/'.$this->command->option('parent');
@ -23,15 +23,15 @@ class ControllerGenerator extends BaseGenerator
}
$controllerPath = $this->makeDirectory(app_path('Http/Controllers'.$parentControllerDirectory));
$controllerPath = $controllerPath.'/'.$pluralModelName.'Controller.php';
$controllerPath = $controllerPath.'/'.$modelName.'Controller.php';
$this->generateFile($controllerPath, $this->getContent('controllers/'.$type));
if ($this->isForApi()) {
$pluralModelName = 'Api/'.$pluralModelName;
$modelName = 'Api/'.$modelName;
}
$this->command->info($pluralModelName.'Controller generated.');
$this->command->info($modelName.'Controller generated.');
}
/**

4
src/Generators/FeatureTestGenerator.php

@ -23,11 +23,11 @@ class FeatureTestGenerator extends BaseGenerator
$featureTestPath = $this->makeDirectory(base_path($featureTestPath));
$this->generateFile(
"{$featureTestPath}/Manage{$this->modelNames['plural_model_name']}Test.php",
"{$featureTestPath}/Manage{$this->modelNames['model_name']}Test.php",
$this->getContent('testcases/feature/'.$type)
);
$this->command->info('Manage'.$this->modelNames['plural_model_name'].'Test generated.');
$this->command->info('Manage'.$this->modelNames['model_name'].'Test generated.');
}
/**

6
src/Generators/RouteGenerator.php

@ -29,11 +29,11 @@ class RouteGenerator extends BaseGenerator
$webRouteFileContent = $this->replaceStubString($stub);
if (!is_null($parentName = $this->command->option('parent'))) {
$pluralModelName = $this->modelNames['plural_model_name'];
$modelName = $this->modelNames['model_name'];
$webRouteFileContent = str_replace(
$pluralModelName.'Controller',
$parentName.'\\'.$pluralModelName.'Controller',
$modelName.'Controller',
$parentName.'\\'.$modelName.'Controller',
$webRouteFileContent
);
}

2
src/stubs/controllers/api.stub

@ -6,7 +6,7 @@ use fullMstr;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class MastersController extends Controller
class MasterController extends Controller
{
/**
* Get a listing of the singleMstr.

2
src/stubs/controllers/full.stub

@ -5,7 +5,7 @@ namespace App\Http\Controllers;
use fullMstr;
use Illuminate\Http\Request;
class MastersController extends Controller
class MasterController extends Controller
{
/**
* Display a listing of the singleMstr.

2
src/stubs/controllers/simple.stub

@ -5,7 +5,7 @@ namespace App\Http\Controllers;
use fullMstr;
use Illuminate\Http\Request;
class MastersController extends Controller
class MasterController extends Controller
{
/**
* Display a listing of the singleMstr.

2
src/stubs/routes/api.stub

@ -2,4 +2,4 @@
/*
* Masters Endpoints
*/
Route::middleware('auth:api')->resource('masters', 'Api\MastersController')->names('api.masters');
Route::middleware('auth:api')->resource('masters', 'Api\MasterController')->names('api.masters');

2
src/stubs/routes/web.stub

@ -2,4 +2,4 @@
/*
* Masters Routes
*/
Route::resource('masters', 'MastersController');
Route::resource('masters', 'MasterController');

2
src/stubs/testcases/feature/api.stub

@ -6,7 +6,7 @@ use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
class ManageMasterTest extends TestCase
{
use DatabaseMigrations;

2
src/stubs/testcases/feature/full.stub

@ -6,7 +6,7 @@ use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
class ManageMasterTest extends TestCase
{
use DatabaseMigrations;

2
src/stubs/testcases/feature/simple.stub

@ -6,7 +6,7 @@ use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
class ManageMasterTest extends TestCase
{
use DatabaseMigrations;

6
tests/CommandOptions/TestsOnlyOptionsTest.php

@ -2,8 +2,8 @@
namespace Tests\CommandOptions;
use Illuminate\Contracts\Console\Kernel;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
class TestOnlyOptionsTest extends TestCase
{
@ -20,7 +20,7 @@ class TestOnlyOptionsTest extends TestCase
$this->assertNotContains("{$this->model_name} model already exists.", $output);
$this->assertFileNotExists(app_path($this->model_name.'.php'));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileNotExists($migrationFilePath);
@ -37,7 +37,7 @@ class TestOnlyOptionsTest extends TestCase
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$this->assertContains('Test files generated successfully!', $output);
}

20
tests/CrudApiMakeCommandTest.php

@ -14,7 +14,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertNotContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileExists(app_path("Http/Controllers/Api/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/Api/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -29,7 +29,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -41,7 +41,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertContains("We will use existing {$this->model_name} model.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileExists(app_path("Http/Controllers/Api/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/Api/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileNotExists($migrationFilePath);
@ -53,7 +53,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileNotExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -65,7 +65,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertContains("We will use existing Problem model.", app(Kernel::class)->output());
$this->assertFileExists(app_path('Entities/Projects/Problem.php'));
$this->assertFileExists(app_path("Http/Controllers/Api/ProblemsController.php"));
$this->assertFileExists(app_path("Http/Controllers/Api/ProblemController.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_problems_table.php');
$this->assertFileNotExists($migrationFilePath);
@ -79,7 +79,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/ManageProblemsTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
@ -101,7 +101,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($modelPath.'/'.$modelName.'.php'));
$this->assertFileExists(app_path("Http/Controllers/Api/{$pluralModelName}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/Api/{$modelName}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$tableName.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -115,7 +115,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$modelName}Test.php"));
}
/** @test */
@ -134,7 +134,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($modelPath.'/'.$modelName.'.php'));
$this->assertFileExists(app_path("Http/Controllers/Api/{$parentName}/{$pluralModelName}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/Api/{$parentName}/{$modelName}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$tableName.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -148,6 +148,6 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$modelName}Test.php"));
}
}

18
tests/CrudMakeCommandTest.php

@ -14,7 +14,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertNotContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -31,7 +31,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -43,7 +43,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileNotExists($migrationFilePath);
@ -60,7 +60,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileNotExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -88,7 +88,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemsTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
@ -110,7 +110,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($modelPath.'/'.$modelName.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$pluralModelName}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$modelName}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$tableName.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -126,7 +126,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
/** @test */
@ -145,7 +145,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($modelPath.'/'.$modelName.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$parentName}/{$pluralModelName}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$parentName}/{$modelName}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$tableName.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -161,6 +161,6 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
}

18
tests/CrudSimpleMakeCommandTest.php

@ -14,7 +14,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertNotContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -29,7 +29,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -41,7 +41,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileNotExists($migrationFilePath);
@ -56,7 +56,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileNotExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -82,7 +82,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemsTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
@ -104,7 +104,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($modelPath.'/'.$modelName.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$pluralModelName}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$modelName}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$tableName.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -118,7 +118,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
/** @test */
@ -137,7 +137,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($modelPath.'/'.$modelName.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$parentName}/{$pluralModelName}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$parentName}/{$modelName}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$tableName.'_table.php');
$this->assertFileExists($migrationFilePath);
@ -151,6 +151,6 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
}

6
tests/Generators/Api/ApiControllerGeneratorTest.php

@ -11,7 +11,7 @@ class ApiControllerGeneratorTest extends TestCase
{
$this->artisan('make:crud-api', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/Api/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/Api/{$this->model_name}Controller.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers\Api;
@ -20,7 +20,7 @@ use {$this->full_model_name};
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class {$this->plural_model_name}Controller extends Controller
class {$this->model_name}Controller extends Controller
{
/**
* Get a listing of the {$this->single_model_var_name}.
@ -116,6 +116,6 @@ class {$this->plural_model_name}Controller extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/Api/{$this->plural_model_name}Controller.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/Api/{$this->model_name}Controller.php")));
}
}

12
tests/Generators/Api/ApiFeatureTestGeneratorTest.php

@ -11,7 +11,7 @@ class ApiFeatureTestGeneratorTest extends TestCase
{
$this->artisan('make:crud-api', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
$featureTestClassContent = "<?php
namespace Tests\Feature\Api;
@ -20,7 +20,7 @@ use {$this->full_model_name};
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -124,7 +124,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php")));
}
/** @test */
@ -135,7 +135,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
$this->artisan('make:crud-api', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
$featureTestClassContent = "<?php
namespace Tests\Feature\Api;
@ -144,7 +144,7 @@ use {$this->full_model_name};
use Tests\TestCase as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -248,6 +248,6 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php")));
}
}

4
tests/Generators/Api/RouteApiGeneratorTest.php

@ -18,7 +18,7 @@ class RouteApiGeneratorTest extends TestCase
/*
* {$this->plural_model_name} Endpoints
*/
Route::middleware('auth:api')->resource('{$this->table_name}', 'Api\\{$this->plural_model_name}Controller')->names('api.{$this->table_name}');
Route::middleware('auth:api')->resource('{$this->table_name}', 'Api\\{$this->model_name}Controller')->names('api.{$this->table_name}');
";
$this->assertEquals($routeApiFileContent, file_get_contents($routeApiPath));
}
@ -35,7 +35,7 @@ Route::middleware('auth:api')->resource('{$this->table_name}', 'Api\\{$this->plu
/*
* {$this->plural_model_name} Endpoints
*/
Route::middleware('auth:api')->resource('{$this->table_name}', 'Api\\Projects\\{$this->plural_model_name}Controller')->names('api.{$this->table_name}');
Route::middleware('auth:api')->resource('{$this->table_name}', 'Api\\Projects\\{$this->model_name}Controller')->names('api.{$this->table_name}');
";
$this->assertEquals($routeApiFileContent, file_get_contents($routeApiPath));
}

12
tests/Generators/FeatureTestGeneratorTest.php

@ -53,7 +53,7 @@ abstract class BrowserKitTest extends BaseTestCase
{
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -62,7 +62,7 @@ use {$this->full_model_name};
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -191,7 +191,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
/** @test */
@ -250,7 +250,7 @@ abstract class {$baseTestClass} extends BaseTestCase
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -259,7 +259,7 @@ use {$this->full_model_name};
use Tests\TestCase as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -388,6 +388,6 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
}

18
tests/Generators/FullControllerGeneratorTest.php

@ -11,7 +11,7 @@ class FullControllerGeneratorTest extends TestCase
{
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers;
@ -19,7 +19,7 @@ namespace App\Http\Controllers;
use {$this->full_model_name};
use Illuminate\Http\Request;
class {$this->plural_model_name}Controller extends Controller
class {$this->model_name}Controller extends Controller
{
/**
* Display a listing of the {$this->single_model_var_name}.
@ -136,7 +136,7 @@ class {$this->plural_model_name}Controller extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/{$this->plural_model_name}Controller.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/{$this->model_name}Controller.php")));
}
/** @test */
@ -144,7 +144,7 @@ class {$this->plural_model_name}Controller extends Controller
{
$this->artisan('make:crud', ['name' => 'Entities/References/Category', '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/CategoriesController.php"));
$this->assertFileExists(app_path("Http/Controllers/CategoryController.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers;
@ -152,7 +152,7 @@ namespace App\Http\Controllers;
use App\Entities\References\Category;
use Illuminate\Http\Request;
class CategoriesController extends Controller
class CategoryController extends Controller
{
/**
* Display a listing of the category.
@ -269,7 +269,7 @@ class CategoriesController extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/CategoriesController.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/CategoryController.php")));
}
/** @test */
@ -277,7 +277,7 @@ class CategoriesController extends Controller
{
$this->artisan('make:crud', ['name' => 'Entities/References/Category', '--parent' => 'Projects', '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/Projects/CategoriesController.php"));
$this->assertFileExists(app_path("Http/Controllers/Projects/CategoryController.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers\Projects;
@ -286,7 +286,7 @@ use App\Entities\References\Category;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class CategoriesController extends Controller
class CategoryController extends Controller
{
/**
* Display a listing of the category.
@ -403,6 +403,6 @@ class CategoriesController extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/Projects/CategoriesController.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/Projects/CategoryController.php")));
}
}

4
tests/Generators/RouteWebGeneratorTest.php

@ -18,7 +18,7 @@ class RouteWebGeneratorTest extends TestCase
/*
* {$this->plural_model_name} Routes
*/
Route::resource('{$this->table_name}', '{$this->plural_model_name}Controller');
Route::resource('{$this->table_name}', '{$this->model_name}Controller');
";
$this->assertEquals($routeWebFileContent, file_get_contents($routeWebPath));
}
@ -35,7 +35,7 @@ Route::resource('{$this->table_name}', '{$this->plural_model_name}Controller');
/*
* {$this->plural_model_name} Routes
*/
Route::resource('{$this->table_name}', 'Projects\\{$this->plural_model_name}Controller');
Route::resource('{$this->table_name}', 'Projects\\{$this->model_name}Controller');
";
$this->assertEquals($routeWebFileContent, file_get_contents($routeWebPath));
}

12
tests/Generators/Simple/FeatureTestGeneratorTest.php

@ -53,7 +53,7 @@ abstract class BrowserKitTest extends BaseTestCase
{
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -62,7 +62,7 @@ use {$this->full_model_name};
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -144,7 +144,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
/** @test */
@ -203,7 +203,7 @@ abstract class {$baseTestClass} extends BaseTestCase
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -212,7 +212,7 @@ use {$this->full_model_name};
use Tests\TestCase as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -294,6 +294,6 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
}

18
tests/Generators/Simple/SimpleControllerGeneratorTest.php

@ -11,7 +11,7 @@ class SimpleControllerGeneratorTest extends TestCase
{
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers;
@ -19,7 +19,7 @@ namespace App\Http\Controllers;
use {$this->full_model_name};
use Illuminate\Http\Request;
class {$this->plural_model_name}Controller extends Controller
class {$this->model_name}Controller extends Controller
{
/**
* Display a listing of the {$this->single_model_var_name}.
@ -107,7 +107,7 @@ class {$this->plural_model_name}Controller extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/{$this->plural_model_name}Controller.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/{$this->model_name}Controller.php")));
}
/** @test */
@ -115,7 +115,7 @@ class {$this->plural_model_name}Controller extends Controller
{
$this->artisan('make:crud-simple', ['name' => 'Entities/References/Category', '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/CategoriesController.php"));
$this->assertFileExists(app_path("Http/Controllers/CategoryController.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers;
@ -123,7 +123,7 @@ namespace App\Http\Controllers;
use App\Entities\References\Category;
use Illuminate\Http\Request;
class CategoriesController extends Controller
class CategoryController extends Controller
{
/**
* Display a listing of the category.
@ -211,7 +211,7 @@ class CategoriesController extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/CategoriesController.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/CategoryController.php")));
}
/** @test */
@ -219,7 +219,7 @@ class CategoriesController extends Controller
{
$this->artisan('make:crud-simple', ['name' => 'Entities/References/Category', '--parent' => 'Projects', '--no-interaction' => true]);
$this->assertFileExists(app_path("Http/Controllers/Projects/CategoriesController.php"));
$this->assertFileExists(app_path("Http/Controllers/Projects/CategoryController.php"));
$ctrlClassContent = "<?php
namespace App\Http\Controllers\Projects;
@ -228,7 +228,7 @@ use App\Entities\References\Category;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class CategoriesController extends Controller
class CategoryController extends Controller
{
/**
* Display a listing of the category.
@ -316,6 +316,6 @@ class CategoriesController extends Controller
}
}
";
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/Projects/CategoriesController.php")));
$this->assertEquals($ctrlClassContent, file_get_contents(app_path("Http/Controllers/Projects/CategoryController.php")));
}
}
Loading…
Cancel
Save