From 500edb79c70e9bd0c46e3f0fa62d7db6fd39d2e7 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Tue, 19 Jan 2021 23:16:24 +0800 Subject: [PATCH] Update unit tests based on the new implementation --- src/stubs/controllers/full-formrequests.stub | 2 +- src/stubs/testcases/feature/full.stub | 4 +- src/stubs/testcases/feature/simple.stub | 12 +- tests/CommandOptions/FullCrudBs3OptionsTest.php | 26 ++-- .../FullCrudFormRequestOptionsTest.php | 6 +- .../FullCrudFormfieldBs3OptionsTest.php | 14 +-- .../FullCrudFormfieldOptionsTest.php | 30 ++--- tests/CommandOptions/SimpleCrudBs3OptionsTest.php | 24 ++-- .../SimpleCrudFormfieldBs3OptionsTest.php | 12 +- .../SimpleCrudFormfieldOptionsTest.php | 12 +- tests/CrudMakeClassPropertiesTest.php | 2 +- .../Generators/Api/ApiControllerGeneratorTest.php | 6 +- .../Generators/Api/ApiFeatureTestGeneratorTest.php | 116 ++++++++--------- tests/Generators/FeatureTestGeneratorTest.php | 140 ++++++++++----------- tests/Generators/FullControllerGeneratorTest.php | 18 +-- tests/Generators/LangGeneratorTest.php | 6 +- tests/Generators/MigrationGeneratorTest.php | 2 +- tests/Generators/ModelFactoryGeneratorTest.php | 2 +- tests/Generators/ModelGeneratorTest.php | 16 +-- tests/Generators/ModelPolicyTestGeneratorTest.php | 2 +- tests/Generators/ModelTestGeneratorTest.php | 26 ++-- .../Generators/Simple/FeatureTestGeneratorTest.php | 108 ++++++++-------- .../Simple/SimpleControllerGeneratorTest.php | 18 +-- tests/Generators/Simple/ViewsGeneratorTest.php | 22 ++-- tests/Generators/ViewsGeneratorTest.php | 24 ++-- 25 files changed, 325 insertions(+), 325 deletions(-) diff --git a/src/stubs/controllers/full-formrequests.stub b/src/stubs/controllers/full-formrequests.stub index 32c3096..1d0e38f 100644 --- a/src/stubs/controllers/full-formrequests.stub +++ b/src/stubs/controllers/full-formrequests.stub @@ -1,6 +1,6 @@ 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ], $overrides); } @@ -81,7 +81,7 @@ class ManageMasterTest extends TestCase private function getEditFields(array $overrides = []) { return array_merge([ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ], $overrides); } diff --git a/src/stubs/testcases/feature/simple.stub b/src/stubs/testcases/feature/simple.stub index 9b8d578..3894781 100644 --- a/src/stubs/testcases/feature/simple.stub +++ b/src/stubs/testcases/feature/simple.stub @@ -30,14 +30,14 @@ class ManageMasterTest extends TestCase $this->seeRouteIs('masters.index', ['action' => 'create']); $this->submitForm(__('master.create'), [ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ]); $this->seeRouteIs('masters.index'); $this->seeInDatabase('masters', [ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ]); } @@ -45,7 +45,7 @@ class ManageMasterTest extends TestCase private function getCreateFields(array $overrides = []) { return array_merge([ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ], $overrides); } @@ -95,14 +95,14 @@ class ManageMasterTest extends TestCase $this->seeRouteIs('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123']); $this->submitForm(__('master.update'), [ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ]); $this->seeRouteIs('masters.index', ['q' => '123']); $this->seeInDatabase('masters', [ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ]); } @@ -110,7 +110,7 @@ class ManageMasterTest extends TestCase private function getEditFields(array $overrides = []) { return array_merge([ - 'title' => 'Master 1 title', + 'title' => 'Master 1 title', 'description' => 'Master 1 description', ], $overrides); } diff --git a/tests/CommandOptions/FullCrudBs3OptionsTest.php b/tests/CommandOptions/FullCrudBs3OptionsTest.php index cfb9d5d..8b2cd98 100644 --- a/tests/CommandOptions/FullCrudBs3OptionsTest.php +++ b/tests/CommandOptions/FullCrudBs3OptionsTest.php @@ -73,7 +73,7 @@ class FullCrudBs3OptionsTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -82,7 +82,7 @@ class FullCrudBs3OptionsTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {!! \${$this->single_model_var_name}->name_link !!} + {!! \${$this->single_model_var_name}->title_link !!} {{ \${$this->single_model_var_name}->description }} @can('view', \${$this->single_model_var_name}) @@ -121,7 +121,7 @@ class FullCrudBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.detail') }}

- +
{{ __('{$this->lang_name}.name') }}{{ \${$this->single_model_var_name}->name }}
{{ __('{$this->lang_name}.title') }}{{ \${$this->single_model_var_name}->title }}
{{ __('{$this->lang_name}.description') }}{{ \${$this->single_model_var_name}->description }}
@@ -158,10 +158,10 @@ class FullCrudBs3OptionsTest extends TestCase
table_name}.store') }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }}
-
has('name') ? ' has-error' : '' }}\"> - - - {!! \$errors->first('name', ':message') !!} +
has('title') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('title', ':message') !!}
has('description') ? ' has-error' : '' }}\"> @@ -201,8 +201,8 @@ class FullCrudBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.delete') }}

- -

{{ \${$this->single_model_var_name}->name }}

+ +

{{ \${$this->single_model_var_name}->title }}

{{ \${$this->single_model_var_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} @@ -225,10 +225,10 @@ class FullCrudBs3OptionsTest extends TestCase table_name}.update', \${$this->single_model_var_name}) }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }} {{ method_field('patch') }}
-
has('name') ? ' has-error' : '' }}\"> - - single_model_var_name}->name) }}\" required> - {!! \$errors->first('name', ':message') !!} +
has('title') ? ' has-error' : '' }}\"> + + single_model_var_name}->title) }}\" required> + {!! \$errors->first('title', ':message') !!}
has('description') ? ' has-error' : '' }}\"> diff --git a/tests/CommandOptions/FullCrudFormRequestOptionsTest.php b/tests/CommandOptions/FullCrudFormRequestOptionsTest.php index a2420c6..9d382d0 100644 --- a/tests/CommandOptions/FullCrudFormRequestOptionsTest.php +++ b/tests/CommandOptions/FullCrudFormRequestOptionsTest.php @@ -62,7 +62,7 @@ class {$this->model_name}Controller extends Controller public function index() { \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); return view('{$this->table_name}.index', compact('{$this->collection_model_var_name}')); @@ -190,7 +190,7 @@ class CreateRequest extends FormRequest public function rules() { return [ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]; } @@ -246,7 +246,7 @@ class UpdateRequest extends FormRequest public function rules() { return [ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]; } diff --git a/tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php b/tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php index 745ff7b..94517e1 100644 --- a/tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php +++ b/tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php @@ -70,7 +70,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -79,7 +79,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->name_link }} + {{ \${$this->single_model_var_name}->title_link }} {{ \${$this->single_model_var_name}->description }} @can('view', \${$this->single_model_var_name}) @@ -123,7 +123,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.detail') }}

- +
{{ __('{$this->lang_name}.name') }}{{ \${$this->single_model_var_name}->name }}
{{ __('{$this->lang_name}.title') }}{{ \${$this->single_model_var_name}->title }}
{{ __('{$this->lang_name}.description') }}{{ \${$this->single_model_var_name}->description }}
@@ -159,7 +159,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.create') }}

{{ Form::open(['route' => '{$this->table_name}.store']) }}
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
@@ -194,8 +194,8 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.delete') }}

- -

{{ \${$this->single_model_var_name}->name }}

+ +

{{ \${$this->single_model_var_name}->title }}

{{ \${$this->single_model_var_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} @@ -218,7 +218,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.edit') }}

{{ Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}], 'method' => 'patch']) }}
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
diff --git a/tests/CommandOptions/FullCrudFormfieldOptionsTest.php b/tests/CommandOptions/FullCrudFormfieldOptionsTest.php index f646a86..e9257bf 100644 --- a/tests/CommandOptions/FullCrudFormfieldOptionsTest.php +++ b/tests/CommandOptions/FullCrudFormfieldOptionsTest.php @@ -70,7 +70,7 @@ class FullCrudFormfieldOptionsTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -79,7 +79,7 @@ class FullCrudFormfieldOptionsTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->name_link }} + {{ \${$this->single_model_var_name}->title_link }} {{ \${$this->single_model_var_name}->description }} @can('view', \${$this->single_model_var_name}) @@ -124,7 +124,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
- +
{{ __('{$this->lang_name}.name') }}{{ \${$this->single_model_var_name}->name }}
{{ __('{$this->lang_name}.title') }}{{ \${$this->single_model_var_name}->title }}
{{ __('{$this->lang_name}.description') }}{{ \${$this->single_model_var_name}->description }}
@@ -161,7 +161,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
{{ __('{$this->lang_name}.create') }}
{{ Form::open(['route' => '{$this->table_name}.store']) }}
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
@@ -196,8 +196,8 @@ class FullCrudFormfieldOptionsTest extends TestCase
{{ __('{$this->lang_name}.delete') }}
- -

{{ \${$this->single_model_var_name}->name }}

+ +

{{ \${$this->single_model_var_name}->title }}

{{ \${$this->single_model_var_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} @@ -220,7 +220,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
{{ __('{$this->lang_name}.edit') }}
{{ Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}], 'method' => 'patch']) }}
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
@@ -260,14 +260,14 @@ class {$this->model_name} extends Model { use HasFactory; - protected \$fillable = ['name', 'description', 'creator_id']; + protected \$fillable = ['title', 'description', 'creator_id']; - public function getNameLinkAttribute() + public function getTitleLinkAttribute() { - return link_to_route('{$this->table_name}.show', \$this->name, [\$this], [ + return link_to_route('{$this->table_name}.show', \$this->title, [\$this], [ 'title' => __( 'app.show_detail_title', - ['name' => \$this->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')] + ['title' => \$this->title, 'type' => __('{$this->lang_name}.{$this->lang_name}')] ), ]); } @@ -303,17 +303,17 @@ class {$this->model_name}Test extends TestCase use RefreshDatabase; /** @test */ - public function a_{$this->lang_name}_has_name_link_attribute() + public function a_{$this->lang_name}_has_title_link_attribute() { \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); \$this->assertEquals( - link_to_route('{$this->table_name}.show', \${$this->single_model_var_name}->name, [\${$this->single_model_var_name}], [ + link_to_route('{$this->table_name}.show', \${$this->single_model_var_name}->title, [\${$this->single_model_var_name}], [ 'title' => __( 'app.show_detail_title', - ['name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')] + ['title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}')] ), - ]), \${$this->single_model_var_name}->name_link + ]), \${$this->single_model_var_name}->title_link ); } diff --git a/tests/CommandOptions/SimpleCrudBs3OptionsTest.php b/tests/CommandOptions/SimpleCrudBs3OptionsTest.php index 74b99bc..6745c86 100644 --- a/tests/CommandOptions/SimpleCrudBs3OptionsTest.php +++ b/tests/CommandOptions/SimpleCrudBs3OptionsTest.php @@ -71,7 +71,7 @@ class SimpleCrudBs3OptionsTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -80,7 +80,7 @@ class SimpleCrudBs3OptionsTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->name }} + {{ \${$this->single_model_var_name}->title }} {{ \${$this->single_model_var_name}->description }} @can('update', \${$this->single_model_var_name}) @@ -116,10 +116,10 @@ class SimpleCrudBs3OptionsTest extends TestCase @can('create', new {$this->full_model_name}) table_name}.store') }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }} -
has('name') ? ' has-error' : '' }}\"> - - - {!! \$errors->first('name', ':message') !!} +
has('title') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('title', ':message') !!}
has('description') ? ' has-error' : '' }}\"> @@ -135,10 +135,10 @@ class SimpleCrudBs3OptionsTest extends TestCase @can('update', \$editable{$this->model_name}) table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }} {{ method_field('patch') }} -
has('name') ? ' has-error' : '' }}\"> - - model_name}->name) }}\" required> - {!! \$errors->first('name', ':message') !!} +
has('title') ? ' has-error' : '' }}\"> + + model_name}->title) }}\" required> + {!! \$errors->first('title', ':message') !!}
has('description') ? ' has-error' : '' }}\"> @@ -160,8 +160,8 @@ class SimpleCrudBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.delete') }}

- -

{{ \$editable{$this->model_name}->name }}

+ +

{{ \$editable{$this->model_name}->title }}

{{ \$editable{$this->model_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} diff --git a/tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php b/tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php index 7d65084..de5550c 100644 --- a/tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php +++ b/tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php @@ -68,7 +68,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -77,7 +77,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->name }} + {{ \${$this->single_model_var_name}->title }} {{ \${$this->single_model_var_name}->description }} @can('update', \${$this->single_model_var_name}) @@ -117,7 +117,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase $formViewContent = "@if (Request::get('action') == 'create') @can('create', new {$this->full_model_name}) {{ Form::open(['route' => '{$this->table_name}.store']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} {{ Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) }} {{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} @@ -127,7 +127,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase @if (Request::get('action') == 'edit' && \$editable{$this->model_name}) @can('update', \$editable{$this->model_name}) {{ Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} @if (request('q')) {{ Form::hidden('q', request('q')) }} @@ -153,8 +153,8 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase

{{ __('{$this->lang_name}.delete') }}

- -

{{ \$editable{$this->model_name}->name }}

+ +

{{ \$editable{$this->model_name}->title }}

{{ \$editable{$this->model_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} diff --git a/tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php b/tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php index 48a61d4..d3fa17d 100644 --- a/tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php +++ b/tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php @@ -68,7 +68,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -77,7 +77,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->name }} + {{ \${$this->single_model_var_name}->title }} {{ \${$this->single_model_var_name}->description }} @can('update', \${$this->single_model_var_name}) @@ -117,7 +117,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase $formViewContent = "@if (Request::get('action') == 'create') @can('create', new {$this->full_model_name}) {{ Form::open(['route' => '{$this->table_name}.store']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} {{ Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) }} {{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-link']) }} @@ -127,7 +127,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase @if (Request::get('action') == 'edit' && \$editable{$this->model_name}) @can('update', \$editable{$this->model_name}) {{ Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} + {!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} @if (request('q')) {{ Form::hidden('q', request('q')) }} @@ -153,8 +153,8 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
{{ __('{$this->lang_name}.delete') }}
- -

{{ \$editable{$this->model_name}->name }}

+ +

{{ \$editable{$this->model_name}->title }}

{{ \$editable{$this->model_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} diff --git a/tests/CrudMakeClassPropertiesTest.php b/tests/CrudMakeClassPropertiesTest.php index 49be9d1..d128e40 100644 --- a/tests/CrudMakeClassPropertiesTest.php +++ b/tests/CrudMakeClassPropertiesTest.php @@ -56,7 +56,7 @@ class CrudMakeClassPropertiesTest extends TestCase } /** @test */ - public function it_set_proper_model_names_property_for_namespaced_model_name_entry() + public function it_set_proper_model_names_property_for_namespaced_model_title_entry() { $this->assertEquals([ 'model_namespace' => 'App\Entities\References', diff --git a/tests/Generators/Api/ApiControllerGeneratorTest.php b/tests/Generators/Api/ApiControllerGeneratorTest.php index a55e5d8..1a27ea6 100644 --- a/tests/Generators/Api/ApiControllerGeneratorTest.php +++ b/tests/Generators/Api/ApiControllerGeneratorTest.php @@ -30,7 +30,7 @@ class {$this->model_name}Controller extends Controller public function index() { \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); return \${$this->collection_model_var_name}; @@ -47,7 +47,7 @@ class {$this->model_name}Controller extends Controller \$this->authorize('create', new {$this->model_name}); \$new{$this->model_name} = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$new{$this->model_name}['creator_id'] = auth()->id(); @@ -83,7 +83,7 @@ class {$this->model_name}Controller extends Controller \$this->authorize('update', \${$this->single_model_var_name}); \${$this->single_model_var_name}Data = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \${$this->single_model_var_name}->update(\${$this->single_model_var_name}Data); diff --git a/tests/Generators/Api/ApiFeatureTestGeneratorTest.php b/tests/Generators/Api/ApiFeatureTestGeneratorTest.php index b0fecb1..e562431 100644 --- a/tests/Generators/Api/ApiFeatureTestGeneratorTest.php +++ b/tests/Generators/Api/ApiFeatureTestGeneratorTest.php @@ -34,7 +34,7 @@ class Manage{$this->model_name}Test extends TestCase 'Authorization' => 'Bearer '.\$user->api_token ]); - \$this->seeJson(['name' => \${$this->single_model_var_name}->name]); + \$this->seeJson(['title' => \${$this->single_model_var_name}->title]); } /** @test */ @@ -43,21 +43,21 @@ class Manage{$this->model_name}Test extends TestCase \$user = \$this->createUser(); \$this->postJson(route('api.{$this->table_name}.store'), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], [ 'Authorization' => 'Bearer '.\$user->api_token ]); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeStatusCode(201); \$this->seeJson([ 'message' => __('{$this->lang_name}.created'), - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -65,18 +65,18 @@ class Manage{$this->model_name}Test extends TestCase private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$user = \$this->createUser(); - // name empty - \$requestBody = \$this->getCreateFields(['name' => '']); + // title empty + \$requestBody = \$this->getCreateFields(['title' => '']); \$this->postJson( route('api.{$this->table_name}.store'), \$requestBody, @@ -84,16 +84,16 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$user = \$this->createUser(); - // name 70 characters - \$requestBody = \$this->getCreateFields(['name' => str_repeat('Test Title', 7)]); + // title 70 characters + \$requestBody = \$this->getCreateFields(['title' => str_repeat('Test Title', 7)]); \$this->postJson( route('api.{$this->table_name}.store'), \$requestBody, @@ -101,7 +101,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ @@ -125,37 +125,37 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_get_a_{$this->lang_name}_detail() { \$user = \$this->createUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->getJson(route('api.{$this->table_name}.show', \${$this->single_model_var_name}), [ 'Authorization' => 'Bearer '.\$user->api_token ]); - \$this->seeJson(['name' => 'Testing 123']); + \$this->seeJson(['title' => 'Testing 123']); } /** @test */ public function user_can_update_a_{$this->lang_name}() { \$user = \$this->createUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->patchJson(route('api.{$this->table_name}.update', \${$this->single_model_var_name}), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], [ 'Authorization' => 'Bearer '.\$user->api_token ]); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeStatusCode(200); \$this->seeJson([ 'message' => __('{$this->lang_name}.updated'), - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -163,19 +163,19 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$user = \$this->createUser(); \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); - // name empty - \$requestBody = \$this->getEditFields(['name' => '']); + // title empty + \$requestBody = \$this->getEditFields(['title' => '']); \$this->patchJson( route('api.{$this->table_name}.update', \${$this->single_model_var_name}), \$requestBody, @@ -183,17 +183,17 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$user = \$this->createUser(); \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); - // name 70 characters - \$requestBody = \$this->getEditFields(['name' => str_repeat('Test Title', 7)]); + // title 70 characters + \$requestBody = \$this->getEditFields(['title' => str_repeat('Test Title', 7)]); \$this->patchJson( route('api.{$this->table_name}.update', \${$this->single_model_var_name}), \$requestBody, @@ -201,14 +201,14 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$user = \$this->createUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$requestBody = \$this->getEditFields(['description' => str_repeat('Long description', 16)]); @@ -279,7 +279,7 @@ class Manage{$this->model_name}Test extends TestCase 'Authorization' => 'Bearer '.\$user->api_token ]); - \$this->seeJson(['name' => \${$this->single_model_var_name}->name]); + \$this->seeJson(['title' => \${$this->single_model_var_name}->title]); } /** @test */ @@ -288,21 +288,21 @@ class Manage{$this->model_name}Test extends TestCase \$user = \$this->createUser(); \$this->postJson(route('api.{$this->table_name}.store'), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], [ 'Authorization' => 'Bearer '.\$user->api_token ]); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeStatusCode(201); \$this->seeJson([ 'message' => __('{$this->lang_name}.created'), - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -310,18 +310,18 @@ class Manage{$this->model_name}Test extends TestCase private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$user = \$this->createUser(); - // name empty - \$requestBody = \$this->getCreateFields(['name' => '']); + // title empty + \$requestBody = \$this->getCreateFields(['title' => '']); \$this->postJson( route('api.{$this->table_name}.store'), \$requestBody, @@ -329,16 +329,16 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$user = \$this->createUser(); - // name 70 characters - \$requestBody = \$this->getCreateFields(['name' => str_repeat('Test Title', 7)]); + // title 70 characters + \$requestBody = \$this->getCreateFields(['title' => str_repeat('Test Title', 7)]); \$this->postJson( route('api.{$this->table_name}.store'), \$requestBody, @@ -346,7 +346,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ @@ -370,37 +370,37 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_get_a_{$this->lang_name}_detail() { \$user = \$this->createUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->getJson(route('api.{$this->table_name}.show', \${$this->single_model_var_name}), [ 'Authorization' => 'Bearer '.\$user->api_token ]); - \$this->seeJson(['name' => 'Testing 123']); + \$this->seeJson(['title' => 'Testing 123']); } /** @test */ public function user_can_update_a_{$this->lang_name}() { \$user = \$this->createUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->patchJson(route('api.{$this->table_name}.update', \${$this->single_model_var_name}), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], [ 'Authorization' => 'Bearer '.\$user->api_token ]); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeStatusCode(200); \$this->seeJson([ 'message' => __('{$this->lang_name}.updated'), - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -408,19 +408,19 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$user = \$this->createUser(); \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); - // name empty - \$requestBody = \$this->getEditFields(['name' => '']); + // title empty + \$requestBody = \$this->getEditFields(['title' => '']); \$this->patchJson( route('api.{$this->table_name}.update', \${$this->single_model_var_name}), \$requestBody, @@ -428,17 +428,17 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$user = \$this->createUser(); \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); - // name 70 characters - \$requestBody = \$this->getEditFields(['name' => str_repeat('Test Title', 7)]); + // title 70 characters + \$requestBody = \$this->getEditFields(['title' => str_repeat('Test Title', 7)]); \$this->patchJson( route('api.{$this->table_name}.update', \${$this->single_model_var_name}), \$requestBody, @@ -446,14 +446,14 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonStructure(['errors' => ['name']]); + \$this->seeJsonStructure(['errors' => ['title']]); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$user = \$this->createUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$requestBody = \$this->getEditFields(['description' => str_repeat('Long description', 16)]); diff --git a/tests/Generators/FeatureTestGeneratorTest.php b/tests/Generators/FeatureTestGeneratorTest.php index a9ac2b7..9daa3dc 100644 --- a/tests/Generators/FeatureTestGeneratorTest.php +++ b/tests/Generators/FeatureTestGeneratorTest.php @@ -67,13 +67,13 @@ class Manage{$this->model_name}Test extends TestCase \$this->loginAsUser(); \$this->visitRoute('{$this->table_name}.index'); - \$this->see(\${$this->single_model_var_name}->name); + \$this->see(\${$this->single_model_var_name}->title); } private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } @@ -95,25 +95,25 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$this->loginAsUser(); - // name empty - \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$this->loginAsUser(); - // name 70 characters + // title 70 characters \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ @@ -131,7 +131,7 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } @@ -140,7 +140,7 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_edit_a_{$this->lang_name}() { \$this->loginAsUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->visitRoute('{$this->table_name}.show', \${$this->single_model_var_name}); \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id); @@ -156,34 +156,34 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name empty - \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name 70 characters + // title 70 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ @@ -284,13 +284,13 @@ class Manage{$this->model_name}Test extends TestCase \$this->loginAsUser(); \$this->visitRoute('{$this->table_name}.index'); - \$this->see(\${$this->single_model_var_name}->name); + \$this->see(\${$this->single_model_var_name}->title); } private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } @@ -312,25 +312,25 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$this->loginAsUser(); - // name empty - \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$this->loginAsUser(); - // name 70 characters + // title 70 characters \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ @@ -348,7 +348,7 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } @@ -357,7 +357,7 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_edit_a_{$this->lang_name}() { \$this->loginAsUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->visitRoute('{$this->table_name}.show', \${$this->single_model_var_name}); \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id); @@ -373,34 +373,34 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name empty - \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name 70 characters + // title 70 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ @@ -432,7 +432,7 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function same_base_test_case_class_name_dont_use_alias() + public function same_base_test_case_class_title_dont_use_alias() { config(['simple-crud.base_test_path' => 'tests/TestCase.php']); config(['simple-crud.base_test_class' => 'Tests\TestCase']); @@ -459,13 +459,13 @@ class Manage{$this->model_name}Test extends TestCase \$this->loginAsUser(); \$this->visitRoute('{$this->table_name}.index'); - \$this->see(\${$this->single_model_var_name}->name); + \$this->see(\${$this->single_model_var_name}->title); } private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } @@ -487,25 +487,25 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$this->loginAsUser(); - // name empty - \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$this->loginAsUser(); - // name 70 characters + // title 70 characters \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ @@ -523,7 +523,7 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } @@ -532,7 +532,7 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_edit_a_{$this->lang_name}() { \$this->loginAsUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->visitRoute('{$this->table_name}.show', \${$this->single_model_var_name}); \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id); @@ -548,34 +548,34 @@ class Manage{$this->model_name}Test extends TestCase } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name empty - \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name 70 characters + // title 70 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ diff --git a/tests/Generators/FullControllerGeneratorTest.php b/tests/Generators/FullControllerGeneratorTest.php index b672dcc..3fdd5b3 100644 --- a/tests/Generators/FullControllerGeneratorTest.php +++ b/tests/Generators/FullControllerGeneratorTest.php @@ -29,7 +29,7 @@ class {$this->model_name}Controller extends Controller public function index() { \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); return view('{$this->table_name}.index', compact('{$this->collection_model_var_name}')); @@ -58,7 +58,7 @@ class {$this->model_name}Controller extends Controller \$this->authorize('create', new {$this->model_name}); \$new{$this->model_name} = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$new{$this->model_name}['creator_id'] = auth()->id(); @@ -104,7 +104,7 @@ class {$this->model_name}Controller extends Controller \$this->authorize('update', \${$this->single_model_var_name}); \${$this->single_model_var_name}Data = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \${$this->single_model_var_name}->update(\${$this->single_model_var_name}Data); @@ -159,7 +159,7 @@ class CategoryController extends Controller public function index() { \$categoryQuery = Category::query(); - \$categoryQuery->where('name', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.request('q').'%'); \$categories = \$categoryQuery->paginate(25); return view('categories.index', compact('categories')); @@ -188,7 +188,7 @@ class CategoryController extends Controller \$this->authorize('create', new Category); \$newCategory = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$newCategory['creator_id'] = auth()->id(); @@ -234,7 +234,7 @@ class CategoryController extends Controller \$this->authorize('update', \$category); \$categoryData = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$category->update(\$categoryData); @@ -290,7 +290,7 @@ class CategoryController extends Controller public function index() { \$categoryQuery = Category::query(); - \$categoryQuery->where('name', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.request('q').'%'); \$categories = \$categoryQuery->paginate(25); return view('categories.index', compact('categories')); @@ -319,7 +319,7 @@ class CategoryController extends Controller \$this->authorize('create', new Category); \$newCategory = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$newCategory['creator_id'] = auth()->id(); @@ -365,7 +365,7 @@ class CategoryController extends Controller \$this->authorize('update', \$category); \$categoryData = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$category->update(\$categoryData); diff --git a/tests/Generators/LangGeneratorTest.php b/tests/Generators/LangGeneratorTest.php index 94e7b7b..e6d3dd8 100644 --- a/tests/Generators/LangGeneratorTest.php +++ b/tests/Generators/LangGeneratorTest.php @@ -2,8 +2,8 @@ namespace Tests\Generators; -use Tests\TestCase; use Illuminate\Support\Str; +use Tests\TestCase; class LangGeneratorTest extends TestCase { @@ -46,7 +46,7 @@ return [ 'undeleteable' => '{$displayModelName} data cannot be deleted.', // Attributes - 'name' => '{$displayModelName} Name', + 'title' => '{$displayModelName} Title', 'description' => '{$displayModelName} Description', ]; "; @@ -93,7 +93,7 @@ return [ 'undeleteable' => 'Data {$displayModelName} tidak dapat dihapus.', // Attributes - 'name' => 'Nama {$displayModelName}', + 'title' => 'Judul {$displayModelName}', 'description' => 'Deskripsi {$displayModelName}', ]; "; diff --git a/tests/Generators/MigrationGeneratorTest.php b/tests/Generators/MigrationGeneratorTest.php index 98254e0..b7b7297 100644 --- a/tests/Generators/MigrationGeneratorTest.php +++ b/tests/Generators/MigrationGeneratorTest.php @@ -30,7 +30,7 @@ class Create{$this->plural_model_name}Table extends Migration { Schema::create('{$this->table_name}', function (Blueprint \$table) { \$table->bigIncrements('id'); - \$table->string('name', 60); + \$table->string('title', 60); \$table->string('description')->nullable(); \$table->unsignedBigInteger('creator_id'); \$table->timestamps(); diff --git a/tests/Generators/ModelFactoryGeneratorTest.php b/tests/Generators/ModelFactoryGeneratorTest.php index 19b9e40..377fffd 100644 --- a/tests/Generators/ModelFactoryGeneratorTest.php +++ b/tests/Generators/ModelFactoryGeneratorTest.php @@ -28,7 +28,7 @@ class {$this->model_name}Factory extends Factory public function definition() { return [ - 'name' => \$this->faker->word, + 'title' => \$this->faker->word, 'description' => \$this->faker->sentence, 'creator_id' => function () { return User::factory()->create()->id; diff --git a/tests/Generators/ModelGeneratorTest.php b/tests/Generators/ModelGeneratorTest.php index d333e3f..c6ab792 100644 --- a/tests/Generators/ModelGeneratorTest.php +++ b/tests/Generators/ModelGeneratorTest.php @@ -26,16 +26,16 @@ class {$this->model_name} extends Model { use HasFactory; - protected \$fillable = ['name', 'description', 'creator_id']; + protected \$fillable = ['title', 'description', 'creator_id']; - public function getNameLinkAttribute() + public function getTitleLinkAttribute() { \$title = __('app.show_detail_title', [ - 'name' => \$this->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'), + 'title' => \$this->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'), ]); \$link = 'table_name}.show', \$this).'\"'; \$link .= ' title=\"'.\$title.'\">'; - \$link .= \$this->name; + \$link .= \$this->title; \$link .= ''; return \$link; @@ -70,16 +70,16 @@ class Category extends Model { use HasFactory; - protected \$fillable = ['name', 'description', 'creator_id']; + protected \$fillable = ['title', 'description', 'creator_id']; - public function getNameLinkAttribute() + public function getTitleLinkAttribute() { \$title = __('app.show_detail_title', [ - 'name' => \$this->name, 'type' => __('category.category'), + 'title' => \$this->title, 'type' => __('category.category'), ]); \$link = ''; - \$link .= \$this->name; + \$link .= \$this->title; \$link .= ''; return \$link; diff --git a/tests/Generators/ModelPolicyTestGeneratorTest.php b/tests/Generators/ModelPolicyTestGeneratorTest.php index 1cbc680..b3306d9 100644 --- a/tests/Generators/ModelPolicyTestGeneratorTest.php +++ b/tests/Generators/ModelPolicyTestGeneratorTest.php @@ -124,7 +124,7 @@ class {$this->model_name}PolicyTest extends TestCase } /** @test */ - public function same_base_test_case_class_name_dont_use_alias() + public function same_base_test_case_class_title_dont_use_alias() { config(['simple-crud.base_test_path' => 'tests/TestCase.php']); config(['simple-crud.base_test_class' => 'Tests\TestCase']); diff --git a/tests/Generators/ModelTestGeneratorTest.php b/tests/Generators/ModelTestGeneratorTest.php index 5db0bd0..7d35317 100644 --- a/tests/Generators/ModelTestGeneratorTest.php +++ b/tests/Generators/ModelTestGeneratorTest.php @@ -28,19 +28,19 @@ class {$this->model_name}Test extends TestCase use RefreshDatabase; /** @test */ - public function a_{$this->lang_name}_has_name_link_attribute() + public function a_{$this->lang_name}_has_title_link_attribute() { \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); \$title = __('app.show_detail_title', [ - 'name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'), + 'title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'), ]); \$link = 'table_name}.show', \${$this->single_model_var_name}).'\"'; \$link .= ' title=\"'.\$title.'\">'; - \$link .= \${$this->single_model_var_name}->name; + \$link .= \${$this->single_model_var_name}->title; \$link .= ''; - \$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link); + \$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link); } /** @test */ @@ -81,19 +81,19 @@ class {$this->model_name}Test extends TestCase use RefreshDatabase; /** @test */ - public function a_{$this->lang_name}_has_name_link_attribute() + public function a_{$this->lang_name}_has_title_link_attribute() { \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); \$title = __('app.show_detail_title', [ - 'name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'), + 'title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'), ]); \$link = 'table_name}.show', \${$this->single_model_var_name}).'\"'; \$link .= ' title=\"'.\$title.'\">'; - \$link .= \${$this->single_model_var_name}->name; + \$link .= \${$this->single_model_var_name}->title; \$link .= ''; - \$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link); + \$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link); } /** @test */ @@ -110,7 +110,7 @@ class {$this->model_name}Test extends TestCase } /** @test */ - public function same_base_test_case_class_name_dont_use_alias() + public function same_base_test_case_class_title_dont_use_alias() { config(['auth.providers.users.model' => 'App\Models\User']); config(['simple-crud.base_test_path' => 'tests/TestCase.php']); @@ -134,19 +134,19 @@ class {$this->model_name}Test extends TestCase use RefreshDatabase; /** @test */ - public function a_{$this->lang_name}_has_name_link_attribute() + public function a_{$this->lang_name}_has_title_link_attribute() { \${$this->single_model_var_name} = {$this->model_name}::factory()->create(); \$title = __('app.show_detail_title', [ - 'name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'), + 'title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'), ]); \$link = 'table_name}.show', \${$this->single_model_var_name}).'\"'; \$link .= ' title=\"'.\$title.'\">'; - \$link .= \${$this->single_model_var_name}->name; + \$link .= \${$this->single_model_var_name}->title; \$link .= ''; - \$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link); + \$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link); } /** @test */ diff --git a/tests/Generators/Simple/FeatureTestGeneratorTest.php b/tests/Generators/Simple/FeatureTestGeneratorTest.php index 9c41a7e..cbbb529 100644 --- a/tests/Generators/Simple/FeatureTestGeneratorTest.php +++ b/tests/Generators/Simple/FeatureTestGeneratorTest.php @@ -67,7 +67,7 @@ class Manage{$this->model_name}Test extends TestCase \$this->loginAsUser(); \$this->visitRoute('{$this->table_name}.index'); - \$this->see(\${$this->single_model_var_name}->name); + \$this->see(\${$this->single_model_var_name}->title); } /** @test */ @@ -80,14 +80,14 @@ class Manage{$this->model_name}Test extends TestCase \$this->seeRouteIs('{$this->table_name}.index', ['action' => 'create']); \$this->submitForm(__('{$this->lang_name}.create'), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeRouteIs('{$this->table_name}.index'); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -95,31 +95,31 @@ class Manage{$this->model_name}Test extends TestCase private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$this->loginAsUser(); - // name empty - \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$this->loginAsUser(); - // name 70 characters + // title 70 characters \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ @@ -138,21 +138,21 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_edit_a_{$this->lang_name}_within_search_query() { \$this->loginAsUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->visitRoute('{$this->table_name}.index', ['q' => '123']); \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id); \$this->seeRouteIs('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']); \$this->submitForm(__('{$this->lang_name}.update'), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeRouteIs('{$this->table_name}.index', ['q' => '123']); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -160,40 +160,40 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name empty - \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name 70 characters + // title 70 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ @@ -298,7 +298,7 @@ class Manage{$this->model_name}Test extends TestCase \$this->loginAsUser(); \$this->visitRoute('{$this->table_name}.index'); - \$this->see(\${$this->single_model_var_name}->name); + \$this->see(\${$this->single_model_var_name}->title); } /** @test */ @@ -311,14 +311,14 @@ class Manage{$this->model_name}Test extends TestCase \$this->seeRouteIs('{$this->table_name}.index', ['action' => 'create']); \$this->submitForm(__('{$this->lang_name}.create'), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeRouteIs('{$this->table_name}.index'); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -326,31 +326,31 @@ class Manage{$this->model_name}Test extends TestCase private function getCreateFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_is_required() + public function validate_{$this->lang_name}_title_is_required() { \$this->loginAsUser(); - // name empty - \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_is_not_more_than_60_characters() { \$this->loginAsUser(); - // name 70 characters + // title 70 characters \$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ @@ -369,21 +369,21 @@ class Manage{$this->model_name}Test extends TestCase public function user_can_edit_a_{$this->lang_name}_within_search_query() { \$this->loginAsUser(); - \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); \$this->visitRoute('{$this->table_name}.index', ['q' => '123']); \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id); \$this->seeRouteIs('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']); \$this->submitForm(__('{$this->lang_name}.update'), [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); \$this->seeRouteIs('{$this->table_name}.index', ['q' => '123']); \$this->seeInDatabase('{$this->table_name}', [ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ]); } @@ -391,40 +391,40 @@ class Manage{$this->model_name}Test extends TestCase private function getEditFields(array \$overrides = []) { return array_merge([ - 'name' => '{$this->model_name} 1 name', + 'title' => '{$this->model_name} 1 title', 'description' => '{$this->model_name} 1 description', ], \$overrides); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_required() + public function validate_{$this->lang_name}_title_update_is_required() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name empty - \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => ''])); - \$this->assertSessionHasErrors('name'); + // title empty + \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => ''])); + \$this->assertSessionHasErrors('title'); } /** @test */ - public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters() + public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); - // name 70 characters + // title 70 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ - 'name' => str_repeat('Test Title', 7), + 'title' => str_repeat('Test Title', 7), ])); - \$this->assertSessionHasErrors('name'); + \$this->assertSessionHasErrors('title'); } /** @test */ public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters() { \$this->loginAsUser(); - \${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']); + \${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']); // description 256 characters \$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([ diff --git a/tests/Generators/Simple/SimpleControllerGeneratorTest.php b/tests/Generators/Simple/SimpleControllerGeneratorTest.php index 677ce4f..7379ae2 100644 --- a/tests/Generators/Simple/SimpleControllerGeneratorTest.php +++ b/tests/Generators/Simple/SimpleControllerGeneratorTest.php @@ -30,7 +30,7 @@ class {$this->model_name}Controller extends Controller { \$editable{$this->model_name} = null; \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { @@ -51,7 +51,7 @@ class {$this->model_name}Controller extends Controller \$this->authorize('create', new {$this->model_name}); \$new{$this->model_name} = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$new{$this->model_name}['creator_id'] = auth()->id(); @@ -73,7 +73,7 @@ class {$this->model_name}Controller extends Controller \$this->authorize('update', \${$this->single_model_var_name}); \${$this->single_model_var_name}Data = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \${$this->single_model_var_name}->update(\${$this->single_model_var_name}Data); @@ -133,7 +133,7 @@ class CategoryController extends Controller { \$editableCategory = null; \$categoryQuery = Category::query(); - \$categoryQuery->where('name', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.request('q').'%'); \$categories = \$categoryQuery->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { @@ -154,7 +154,7 @@ class CategoryController extends Controller \$this->authorize('create', new Category); \$newCategory = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$newCategory['creator_id'] = auth()->id(); @@ -176,7 +176,7 @@ class CategoryController extends Controller \$this->authorize('update', \$category); \$categoryData = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$category->update(\$categoryData); @@ -237,7 +237,7 @@ class CategoryController extends Controller { \$editableCategory = null; \$categoryQuery = Category::query(); - \$categoryQuery->where('name', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.request('q').'%'); \$categories = \$categoryQuery->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { @@ -258,7 +258,7 @@ class CategoryController extends Controller \$this->authorize('create', new Category); \$newCategory = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$newCategory['creator_id'] = auth()->id(); @@ -280,7 +280,7 @@ class CategoryController extends Controller \$this->authorize('update', \$category); \$categoryData = \$request->validate([ - 'name' => 'required|max:60', + 'title' => 'required|max:60', 'description' => 'nullable|max:255', ]); \$category->update(\$categoryData); diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index d470af6..ac5451f 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -2,8 +2,8 @@ namespace Tests\Generators\Simple; -use Tests\TestCase; use Illuminate\Contracts\Console\Kernel; +use Tests\TestCase; class ViewsGeneratorTest extends TestCase { @@ -45,7 +45,7 @@ class ViewsGeneratorTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -54,7 +54,7 @@ class ViewsGeneratorTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {{ \${$this->single_model_var_name}->name }} + {{ \${$this->single_model_var_name}->title }} {{ \${$this->single_model_var_name}->description }} @can('update', \${$this->single_model_var_name}) @@ -91,9 +91,9 @@ class ViewsGeneratorTest extends TestCase table_name}.store') }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }}
- - has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required> - {!! \$errors->first('name', ':message') !!} + + has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title') }}\" required> + {!! \$errors->first('title', ':message') !!}
@@ -110,9 +110,9 @@ class ViewsGeneratorTest extends TestCase table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }} {{ method_field('patch') }}
- - has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \$editable{$this->model_name}->name) }}\" required> - {!! \$errors->first('name', ':message') !!} + + has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title', \$editable{$this->model_name}->title) }}\" required> + {!! \$errors->first('title', ':message') !!}
@@ -134,8 +134,8 @@ class ViewsGeneratorTest extends TestCase
{{ __('{$this->lang_name}.delete') }}
- -

{{ \$editable{$this->model_name}->name }}

+ +

{{ \$editable{$this->model_name}->title }}

{{ \$editable{$this->model_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 3d062ef..5ce6094 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -2,8 +2,8 @@ namespace Tests\Generators; -use Tests\TestCase; use Illuminate\Contracts\Console\Kernel; +use Tests\TestCase; class ViewsGeneratorTest extends TestCase { @@ -45,7 +45,7 @@ class ViewsGeneratorTest extends TestCase {{ __('app.table_no') }} - {{ __('{$this->lang_name}.name') }} + {{ __('{$this->lang_name}.title') }} {{ __('{$this->lang_name}.description') }} {{ __('app.action') }} @@ -54,7 +54,7 @@ class ViewsGeneratorTest extends TestCase @foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name}) {{ \${$this->collection_model_var_name}->firstItem() + \$key }} - {!! \${$this->single_model_var_name}->name_link !!} + {!! \${$this->single_model_var_name}->title_link !!} {{ \${$this->single_model_var_name}->description }} @can('view', \${$this->single_model_var_name}) @@ -93,7 +93,7 @@ class ViewsGeneratorTest extends TestCase
- +
{{ __('{$this->lang_name}.name') }}{{ \${$this->single_model_var_name}->name }}
{{ __('{$this->lang_name}.title') }}{{ \${$this->single_model_var_name}->title }}
{{ __('{$this->lang_name}.description') }}{{ \${$this->single_model_var_name}->description }}
@@ -132,9 +132,9 @@ class ViewsGeneratorTest extends TestCase {{ csrf_field() }}
- - has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required> - {!! \$errors->first('name', ':message') !!} + + has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title') }}\" required> + {!! \$errors->first('title', ':message') !!}
@@ -174,8 +174,8 @@ class ViewsGeneratorTest extends TestCase
{{ __('{$this->lang_name}.delete') }}
- -

{{ \${$this->single_model_var_name}->name }}

+ +

{{ \${$this->single_model_var_name}->title }}

{{ \${$this->single_model_var_name}->description }}

{!! \$errors->first('{$this->lang_name}_id', ':message') !!} @@ -199,9 +199,9 @@ class ViewsGeneratorTest extends TestCase {{ csrf_field() }} {{ method_field('patch') }}
- - has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \${$this->single_model_var_name}->name) }}\" required> - {!! \$errors->first('name', ':message') !!} + + has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title', \${$this->single_model_var_name}->title) }}\" required> + {!! \$errors->first('title', ':message') !!}