{!! $sol !!} namespace Tests\Feature\{{class_basename($model)}}; use App\Models\{{class_basename($model)}}; use App\Documents\UserDocument; use Tests\Bootstrap; use Illuminate\Support\Arr; class {{class_basename($model)}}StoreTest extends Bootstrap { public function test_{{lcfirst(class_basename($model))}}_store_success() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.store']) ->loginAs(['{{$model->getTable()}}.store']) ->postJson(route('api.{{$model->getTable()}}.store'), ${{lcfirst(class_basename($model))}} = $this->make({{class_basename($model)}}::class)) ->assertCreated(); } /** * @testWith @foreach ($model->factory()->list() as $field) * ["{{$field}}"] @endforeach */ public function test_{{lcfirst(class_basename($model))}}_store_unprocessable($field) { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.store']) ->loginAsAdmin() ->postJson(route("api.{{$model->getTable()}}.store"), ${{lcfirst(class_basename($model))}} = $this->make({{lcfirst(class_basename($model))}}::class, smash: $field, withDependency: true)) ->assertUnprocessable(); } public function test_{{lcfirst(class_basename($model))}}_store_forbidden() { $this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.store']) ->loginAs(['wrong.permission']) ->postJson(route("api.{{$model->getTable()}}.store"), []) ->assertForbidden(); } }