You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
42 lines
1.6 KiB
{!! $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();
|
|
}
|
|
}
|