{!! $sol !!} namespace Tests\Feature\{{class_basename($model)}}; use App\Models\{{class_basename($model)}}; use Tests\Bootstrap; use App\Models\User; use Illuminate\Support\Arr; class {{class_basename($model)}}UpdateTest extends Bootstrap { public function test_{{lcfirst(class_basename($model))}}_update_success() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.update']) ->loginAs(['{{$model->getTable()}}.update']) ->putJson( route("api.{{$model->getTable()}}.update", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)), $update = $this->make({{class_basename($model)}}::class, withDependency: true) ) ->assertOk(); } /** * @testWith @foreach ($model->factory()->list() as $field) * ["{{$field}}"] @endforeach */ public function test_{{lcfirst(class_basename($model))}}_update_unprocessable($field) { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.update']) ->loginAs(['{{$model->getTable()}}.update'])->putJson( route("api.{{$model->getTable()}}.update", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)), $update = $this->make({{lcfirst(class_basename($model))}}::class, smash: $field, withDependency: true) ) ->assertUnprocessable(); } public function test_{{lcfirst(class_basename($model))}}_update_forbidden() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.update']) ->loginAs(['wrong.permission']) ->putJson( route("api.{{$model->getTable()}}.update", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)), [] ) ->assertForbidden(); } public function test_{{lcfirst(class_basename($model))}}_update_not_found() { $this->loginAsUser(['{{$model->getTable()}}.update']) ->putJson(route("api.{{$model->getTable()}}.update", 0), []) ->assertNotFound(); } }