Browse Source

Update stub files to fix usage failure tests on laravel 5.5

tags/1.0.0
Nafies Luthfi 8 years ago
parent
commit
a70e86e42e
  1. 4
      src/stubs/controller.full.stub
  2. 4
      src/stubs/test-feature-full.stub
  3. 4
      src/stubs/test-feature-simple.stub
  4. 32
      src/stubs/view-edit.stub
  5. 4
      src/stubs/view-index-full.stub
  6. 4
      src/stubs/view-index-simple.stub
  7. 3
      src/stubs/view-show.stub
  8. 8
      tests/Generators/FeatureTestGeneratorTest.php
  9. 12
      tests/Generators/FullControllerGeneratorTest.php
  10. 8
      tests/Generators/Simple/FeatureTestGeneratorTest.php
  11. 4
      tests/Generators/Simple/ViewsGeneratorTest.php
  12. 39
      tests/Generators/ViewsGeneratorTest.php

4
src/stubs/controller.full.stub

@ -94,11 +94,9 @@ class MastersController extends Controller
'description' => 'nullable|max:255',
]);
$routeParam = request()->only('page', 'q');
$singleMstr = $singleMstr->update($request->only('name', 'description'));
return redirect()->route('masters.index', $routeParam);
return redirect()->route('masters.show', $singleMstr);
}
/**

4
src/stubs/test-feature-full.stub

@ -51,7 +51,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create(['name' => 'Testing 123']);
$this->visit(route('masters.show', $singleMstr));
$this->click('edit-singleMstr-'.$singleMstr->id);
$this->click('edit-master-'.$singleMstr->id);
$this->seePageIs(route('masters.edit', $singleMstr));
$this->submitForm(trans('master.update'), [
@ -75,7 +75,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create();
$this->visit(route('masters.edit', $singleMstr));
$this->click('del-singleMstr-'.$singleMstr->id);
$this->click('del-master-'.$singleMstr->id);
$this->seePageIs(route('masters.edit', [$singleMstr, 'action' => 'delete']));
$this->press(trans('app.delete_confirm_button'));

4
src/stubs/test-feature-simple.stub

@ -50,7 +50,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create(['name' => 'Testing 123']);
$this->visit(route('masters.index', ['q' => '123']));
$this->click('edit-singleMstr-'.$singleMstr->id);
$this->click('edit-master-'.$singleMstr->id);
$this->seePageIs(route('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123']));
$this->type('Master 1 name', 'name');
@ -72,7 +72,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create();
$this->visit(route('masters.index', [$singleMstr->id]));
$this->click('del-singleMstr-'.$singleMstr->id);
$this->click('del-master-'.$singleMstr->id);
$this->seePageIs(route('masters.index', ['action' => 'delete', 'id' => $singleMstr->id]));
$this->seeInDatabase('masters', [

32
src/stubs/view-edit.stub

@ -3,8 +3,38 @@
@section('title', trans('master.edit'))
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
@if (request('action') == 'delete' && $singleMstr)
@can('delete', $singleMstr)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ trans('master.name') }}</label>
<p>{{ $singleMstr->name }}</p>
<label class="control-label">{{ trans('master.description') }}</label>
<p>{{ $singleMstr->description }}</p>
{!! $errors->first('master_id', '<span class="form-error small">:message</span>') !!}
</div>
<hr style="margin:0">
<div class="panel-body">{{ trans('app.delete_confirm') }}</div>
<div class="panel-footer">
{!! FormField::delete(
['route'=>['masters.destroy', $singleMstr]],
trans('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'master_id' => $singleMstr->id,
'page' => request('page'),
'q' => request('q'),
]
) !!}
{{ link_to_route('masters.edit', trans('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan
@else
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.edit') }}</h3></div>
{!! Form::model($singleMstr, ['route' => ['masters.update', $singleMstr->id],'method' => 'patch']) !!}
@ -15,9 +45,11 @@
<div class="panel-footer">
{!! Form::submit(trans('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.show', trans('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.edit', trans('app.delete'), [$singleMstr, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-master-'.$singleMstr->id]) }}
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@endif
@endsection

4
src/stubs/view-index-full.stub

@ -35,7 +35,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->nameLink() }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('view', $singleMstr)
@ -43,7 +43,7 @@
'masters.show',
trans('app.show'),
[$singleMstr],
['class' => 'btn btn-default', 'id' => 'show-master-' . $singleMstr->id]
['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id]
) !!}
@endcan
</td>

4
src/stubs/view-index-simple.stub

@ -43,7 +43,7 @@
'masters.index',
trans('app.edit'),
['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'edit-singleMstr-' . $singleMstr->id]
['id' => 'edit-master-'.$singleMstr->id]
) !!} |
@endcan
@can('delete', $singleMstr)
@ -51,7 +51,7 @@
'masters.index',
trans('app.delete'),
['action' => 'delete', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'del-singleMstr-' . $singleMstr->id]
['id' => 'del-master-'.$singleMstr->id]
) !!}
@endcan
</td>

3
src/stubs/view-show.stub

@ -20,7 +20,8 @@
</tbody>
</table>
<div class="panel-footer">
{{ link_to_route('masters.edit', trans('app.edit'), [$singleMstr], ['class' => 'btn btn-default', 'id' => 'edit-master-'.$singleMstr->id]) }}
{{ link_to_route('masters.edit', trans('master.edit'), [$singleMstr], ['class' => 'btn btn-warning', 'id' => 'edit-master-'.$singleMstr->id]) }}
{{ link_to_route('masters.index', trans('master.back_to_index'), [], ['class' => 'btn btn-default']) }}
</div>
</div>
</div>

8
tests/Generators/FeatureTestGeneratorTest.php

@ -102,7 +102,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.show', \${$this->single_model_var_name}));
\$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
\$this->submitForm(trans('{$this->lang_name}.update'), [
@ -126,7 +126,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
\$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', [\${$this->single_model_var_name}, 'action' => 'delete']));
\$this->press(trans('app.delete_confirm_button'));
@ -245,7 +245,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.show', \${$this->single_model_var_name}));
\$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
\$this->submitForm(trans('{$this->lang_name}.update'), [
@ -269,7 +269,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
\$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', [\${$this->single_model_var_name}, 'action' => 'delete']));
\$this->press(trans('app.delete_confirm_button'));

12
tests/Generators/FullControllerGeneratorTest.php

@ -108,11 +108,9 @@ class {$this->plural_model_name}Controller extends Controller
'description' => 'nullable|max:255',
]);
\$routeParam = request()->only('page', 'q');
\${$this->single_model_var_name} = \${$this->single_model_var_name}->update(\$request->only('name', 'description'));
return redirect()->route('{$this->table_name}.index', \$routeParam);
return redirect()->route('{$this->table_name}.show', \${$this->single_model_var_name});
}
/**
@ -244,11 +242,9 @@ class CategoriesController extends Controller
'description' => 'nullable|max:255',
]);
\$routeParam = request()->only('page', 'q');
\$category = \$category->update(\$request->only('name', 'description'));
return redirect()->route('categories.index', \$routeParam);
return redirect()->route('categories.show', \$category);
}
/**
@ -381,11 +377,9 @@ class CategoriesController extends Controller
'description' => 'nullable|max:255',
]);
\$routeParam = request()->only('page', 'q');
\$category = \$category->update(\$request->only('name', 'description'));
return redirect()->route('categories.index', \$routeParam);
return redirect()->route('categories.show', \$category);
}
/**

8
tests/Generators/Simple/FeatureTestGeneratorTest.php

@ -101,7 +101,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.index', ['q' => '123']));
\$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']));
\$this->type('{$this->model_name} 1 name', 'name');
@ -123,7 +123,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.index', [\${$this->single_model_var_name}->id]));
\$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id]));
\$this->seeInDatabase('{$this->table_name}', [
@ -245,7 +245,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.index', ['q' => '123']));
\$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']));
\$this->type('{$this->model_name} 1 name', 'name');
@ -267,7 +267,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.index', [\${$this->single_model_var_name}->id]));
\$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
\$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id]));
\$this->seeInDatabase('{$this->table_name}', [

4
tests/Generators/Simple/ViewsGeneratorTest.php

@ -59,7 +59,7 @@ class ViewsGeneratorTest extends TestCase
'{$this->table_name}.index',
trans('app.edit'),
['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
['id' => 'edit-{$this->single_model_var_name}-' . \${$this->single_model_var_name}->id]
['id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]
) !!} |
@endcan
@can('delete', \${$this->single_model_var_name})
@ -67,7 +67,7 @@ class ViewsGeneratorTest extends TestCase
'{$this->table_name}.index',
trans('app.delete'),
['action' => 'delete', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
['id' => 'del-{$this->single_model_var_name}-' . \${$this->single_model_var_name}->id]
['id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]
) !!}
@endcan
</td>

39
tests/Generators/ViewsGeneratorTest.php

@ -51,7 +51,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}->nameLink() }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -59,7 +59,7 @@ class ViewsGeneratorTest extends TestCase
'{$this->table_name}.show',
trans('app.show'),
[\${$this->single_model_var_name}],
['class' => 'btn btn-default', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id]
['class' => 'btn btn-default btn-xs', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id]
) !!}
@endcan
</td>
@ -105,7 +105,8 @@ class ViewsGeneratorTest extends TestCase
</tbody>
</table>
<div class=\"panel-footer\">
{{ link_to_route('{$this->table_name}.edit', trans('app.edit'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default', 'id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
{{ link_to_route('{$this->table_name}.edit', trans('{$this->lang_name}.edit'), [\${$this->single_model_var_name}], ['class' => 'btn btn-warning', 'id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
{{ link_to_route('{$this->table_name}.index', trans('{$this->lang_name}.back_to_index'), [], ['class' => 'btn btn-default']) }}
</div>
</div>
</div>
@ -161,8 +162,38 @@ class ViewsGeneratorTest extends TestCase
@section('title', trans('{$this->lang_name}.edit'))
@section('content')
<div class=\"row\">
<div class=\"col-md-6 col-md-offset-3\">
@if (request('action') == 'delete' && \${$this->single_model_var_name})
@can('delete', \${$this->single_model_var_name})
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ trans('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label\">{{ trans('{$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>') !!}
</div>
<hr style=\"margin:0\">
<div class=\"panel-body\">{{ trans('app.delete_confirm') }}</div>
<div class=\"panel-footer\">
{!! FormField::delete(
['route'=>['{$this->table_name}.destroy', \${$this->single_model_var_name}]],
trans('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'{$this->lang_name}_id' => \${$this->single_model_var_name}->id,
'page' => request('page'),
'q' => request('q'),
]
) !!}
{{ link_to_route('{$this->table_name}.edit', trans('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan
@else
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.edit') }}</h3></div>
{!! Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}->id],'method' => 'patch']) !!}
@ -173,11 +204,13 @@ class ViewsGeneratorTest extends TestCase
<div class=\"panel-footer\">
{!! Form::submit(trans('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.show', trans('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }}
{{ link_to_route('{$this->table_name}.edit', trans('app.delete'), [\${$this->single_model_var_name}, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@endif
@endsection
";
$this->assertEquals($editFormViewContent, file_get_contents($editFormViewPath));

Loading…
Cancel
Save