Browse Source

Update unit tests based on the new implementation

pull/29/head
Nafies Luthfi 5 years ago
parent
commit
500edb79c7
  1. 2
      src/stubs/controllers/full-formrequests.stub
  2. 4
      src/stubs/testcases/feature/full.stub
  3. 12
      src/stubs/testcases/feature/simple.stub
  4. 26
      tests/CommandOptions/FullCrudBs3OptionsTest.php
  5. 6
      tests/CommandOptions/FullCrudFormRequestOptionsTest.php
  6. 14
      tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php
  7. 30
      tests/CommandOptions/FullCrudFormfieldOptionsTest.php
  8. 24
      tests/CommandOptions/SimpleCrudBs3OptionsTest.php
  9. 12
      tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php
  10. 12
      tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php
  11. 2
      tests/CrudMakeClassPropertiesTest.php
  12. 6
      tests/Generators/Api/ApiControllerGeneratorTest.php
  13. 116
      tests/Generators/Api/ApiFeatureTestGeneratorTest.php
  14. 140
      tests/Generators/FeatureTestGeneratorTest.php
  15. 18
      tests/Generators/FullControllerGeneratorTest.php
  16. 6
      tests/Generators/LangGeneratorTest.php
  17. 2
      tests/Generators/MigrationGeneratorTest.php
  18. 2
      tests/Generators/ModelFactoryGeneratorTest.php
  19. 16
      tests/Generators/ModelGeneratorTest.php
  20. 2
      tests/Generators/ModelPolicyTestGeneratorTest.php
  21. 26
      tests/Generators/ModelTestGeneratorTest.php
  22. 108
      tests/Generators/Simple/FeatureTestGeneratorTest.php
  23. 18
      tests/Generators/Simple/SimpleControllerGeneratorTest.php
  24. 22
      tests/Generators/Simple/ViewsGeneratorTest.php
  25. 24
      tests/Generators/ViewsGeneratorTest.php

2
src/stubs/controllers/full-formrequests.stub

@ -1,6 +1,6 @@
<?php
titlespace App\Http\Controllers;
namespace App\Http\Controllers;
use fullMstr;
use Illuminate\Http\Request;

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

@ -23,7 +23,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);
}
@ -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);
}

12
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);
}

26
tests/CommandOptions/FullCrudBs3OptionsTest.php

@ -73,7 +73,7 @@ class FullCrudBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -82,7 +82,7 @@ class FullCrudBs3OptionsTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{!! \${$this->single_model_var_name}->name_link !!}</td>
<td>{!! \${$this->single_model_var_name}->title_link !!}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -121,7 +121,7 @@ class FullCrudBs3OptionsTest extends TestCase
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.detail') }}</h3></div>
<table class=\"table table-condensed\">
<tbody>
<tr><td>{{ __('{$this->lang_name}.name') }}</td><td>{{ \${$this->single_model_var_name}->name }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -158,10 +158,10 @@ class FullCrudBs3OptionsTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.store') }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }}
<div class=\"panel-body\">
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -201,8 +201,8 @@ class FullCrudBs3OptionsTest extends TestCase
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \${$this->single_model_var_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}
@ -225,10 +225,10 @@ class FullCrudBs3OptionsTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.update', \${$this->single_model_var_name}) }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"panel-body\">
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name', \${$this->single_model_var_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title', \${$this->single_model_var_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>

6
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',
];
}

14
tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php

@ -70,7 +70,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -79,7 +79,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name_link }}</td>
<td>{{ \${$this->single_model_var_name}->title_link }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -123,7 +123,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.detail') }}</h3></div>
<table class=\"table table-condensed\">
<tbody>
<tr><td>{{ __('{$this->lang_name}.name') }}</td><td>{{ \${$this->single_model_var_name}->name }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -159,7 +159,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.create') }}</h3></div>
{{ Form::open(['route' => '{$this->table_name}.store']) }}
<div class=\"panel-body\">
{!! 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')]) !!}
</div>
<div class=\"panel-footer\">
@ -194,8 +194,8 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \${$this->single_model_var_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}
@ -218,7 +218,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.edit') }}</h3></div>
{{ Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}], 'method' => 'patch']) }}
<div class=\"panel-body\">
{!! 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')]) !!}
</div>
<div class=\"panel-footer\">

30
tests/CommandOptions/FullCrudFormfieldOptionsTest.php

@ -70,7 +70,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -79,7 +79,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name_link }}</td>
<td>{{ \${$this->single_model_var_name}->title_link }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -124,7 +124,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<div class=\"card-body\">
<table class=\"table table-sm\">
<tbody>
<tr><td>{{ __('{$this->lang_name}.name') }}</td><td>{{ \${$this->single_model_var_name}->name }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -161,7 +161,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<div class=\"card-header\">{{ __('{$this->lang_name}.create') }}</div>
{{ Form::open(['route' => '{$this->table_name}.store']) }}
<div class=\"card-body\">
{!! 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')]) !!}
</div>
<div class=\"card-footer\">
@ -196,8 +196,8 @@ class FullCrudFormfieldOptionsTest extends TestCase
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \${$this->single_model_var_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}
@ -220,7 +220,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<div class=\"card-header\">{{ __('{$this->lang_name}.edit') }}</div>
{{ Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}], 'method' => 'patch']) }}
<div class=\"card-body\">
{!! 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')]) !!}
</div>
<div class=\"card-footer\">
@ -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
);
}

24
tests/CommandOptions/SimpleCrudBs3OptionsTest.php

@ -71,7 +71,7 @@ class SimpleCrudBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -80,7 +80,7 @@ class SimpleCrudBs3OptionsTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name }}</td>
<td>{{ \${$this->single_model_var_name}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
@ -116,10 +116,10 @@ class SimpleCrudBs3OptionsTest extends TestCase
@can('create', new {$this->full_model_name})
<form method=\"POST\" action=\"{{ route('{$this->table_name}.store') }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }}
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -135,10 +135,10 @@ class SimpleCrudBs3OptionsTest extends TestCase
@can('update', \$editable{$this->model_name})
<form method=\"POST\" action=\"{{ route('{$this->table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name', \$editable{$this->model_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title', \$editable{$this->model_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -160,8 +160,8 @@ class SimpleCrudBs3OptionsTest extends TestCase
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \$editable{$this->model_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}

12
tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php

@ -68,7 +68,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -77,7 +77,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name }}</td>
<td>{{ \${$this->single_model_var_name}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@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
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \$editable{$this->model_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}

12
tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php

@ -68,7 +68,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -77,7 +77,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name }}</td>
<td>{{ \${$this->single_model_var_name}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@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
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \$editable{$this->model_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}

2
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',

6
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);

116
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)]);

140
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([

18
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);

6
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}',
];
";

2
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();

2
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;

16
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 = '<a href=\"'.route('{$this->table_name}.show', \$this).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \$this->name;
\$link .= \$this->title;
\$link .= '</a>';
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 = '<a href=\"'.route('categories.show', \$this).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \$this->name;
\$link .= \$this->title;
\$link .= '</a>';
return \$link;

2
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']);

26
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 = '<a href=\"'.route('{$this->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 .= '</a>';
\$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 = '<a href=\"'.route('{$this->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 .= '</a>';
\$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 = '<a href=\"'.route('{$this->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 .= '</a>';
\$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link);
\$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link);
}
/** @test */

108
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([

18
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);

22
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
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -54,7 +54,7 @@ class ViewsGeneratorTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name }}</td>
<td>{{ \${$this->single_model_var_name}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
@ -91,9 +91,9 @@ class ViewsGeneratorTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.store') }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }}
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -110,9 +110,9 @@ class ViewsGeneratorTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \$editable{$this->model_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title', \$editable{$this->model_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -134,8 +134,8 @@ class ViewsGeneratorTest extends TestCase
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \$editable{$this->model_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}

24
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
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -54,7 +54,7 @@ class ViewsGeneratorTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{!! \${$this->single_model_var_name}->name_link !!}</td>
<td>{!! \${$this->single_model_var_name}->title_link !!}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -93,7 +93,7 @@ class ViewsGeneratorTest extends TestCase
<div class=\"card-body\">
<table class=\"table table-sm\">
<tbody>
<tr><td>{{ __('{$this->lang_name}.name') }}</td><td>{{ \${$this->single_model_var_name}->name }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -132,9 +132,9 @@ class ViewsGeneratorTest extends TestCase
{{ csrf_field() }}
<div class=\"card-body\">
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -174,8 +174,8 @@ class ViewsGeneratorTest extends TestCase
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \${$this->single_model_var_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
@ -199,9 +199,9 @@ class ViewsGeneratorTest extends TestCase
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"card-body\">
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \${$this->single_model_var_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title', \${$this->single_model_var_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>

Loading…
Cancel
Save