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.
 
 
 
 

34 lines
1.4 KiB

{!! $sol !!}
namespace Tests\Feature\{{class_basename($model)}};
use App\Models\{{class_basename($model)}};
use Tests\Bootstrap;
use App\Models\User;
class {{class_basename($model)}}ShowTest extends Bootstrap
{
public function test_{{lcfirst(class_basename($model))}}_show_success()
{
$this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.show'])
->loginAs(['{{$model->getTable()}}.show'])
->getJson(route("api.{{$model->getTable()}}.show", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)))
->assertOk();
}
public function test_{{lcfirst(class_basename($model))}}_show_not_found()
{
$this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.show'])
->loginAs(['{{$model->getTable()}}.show'])
->getJson(route("api.{{$model->getTable()}}.show", 0))
->assertNotFound();
}
public function test_{{lcfirst(class_basename($model))}}_show_forbidden()
{
$this->modelWithPolicy('{{$model->getTable()}}', ['permission:{{$model->getTable()}}.show'])
->loginAs(['wrong.permission'])
->getJson(route("api.{{$model->getTable()}}.show", ${{lcfirst(class_basename($model))}} = $this->one({{class_basename($model)}}::class)), [])
->assertForbidden();
}
}