File manager - Edit - /var/www/html/spdc/api/tests/Feature/FormTest.php
Back
<?php namespace Tests\Feature; use Tests\BaseTest; use App\Models\Form; use Illuminate\Http\JsonResponse; use AluisioPires\LaravelBaseTest\BaseTestTransactions; class FormTest extends BaseTest { public function test_index() { // deleting existing forms Form::query()->delete(); // creating two forms Form::factory(2)->create(); $response = $this->authRequest( 'get', route('form.index'), JsonResponse::HTTP_OK ); $response->assertJsonCount(2, 'data.data'); } public function test_index_with_search() { // deleting existing forms Form::query()->delete(); // creating two forms $forms = Form::factory(2)->create(); $searchTerm = substr($forms[0]->name, strlen($forms[0]->name) - 3, strlen($forms[0]->name)); $response = $this->authRequest( 'get', route('form.index', [ 'search_term' => $searchTerm ]), JsonResponse::HTTP_OK ); } public function test_index_without_pages() { // deleting existing forms Form::query()->delete(); // creating two forms $forms = Form::factory(2)->create(); $searchTerm = substr($forms[0]->name, strlen($forms[0]->name) - 3, strlen($forms[0]->name)); $response = $this->authRequest( 'get', route('form.index', [ 'without_pages' => 1 ]), JsonResponse::HTTP_OK ); } public function test_store() { // deleting existing forms Form::query()->delete(); // creating a text form $response = $this->authRequest( 'post', route('form.store'), JsonResponse::HTTP_CREATED, Form::factory()->request()->make()->toArray() ); } public function test_store_with_invalid_fields() { // deleting existing forms Form::query()->delete(); // creating a text form $response = $this->authRequest( 'post', route('form.store'), JsonResponse::HTTP_UNPROCESSABLE_ENTITY, Form::factory()->invalidRequest()->make()->toArray() ); } public function test_store_without_required_fields() { // deleting existing forms Form::query()->delete(); $response = $this->authRequest( 'post', route('form.store'), JsonResponse::HTTP_UNPROCESSABLE_ENTITY, Form::factory()->make()->toArray() ); $response = $this->authRequest( 'post', route('form.store'), JsonResponse::HTTP_UNPROCESSABLE_ENTITY, Form::factory()->withoutName()->make()->toArray() ); } public function test_show() { // deleting existing forms Form::query()->delete(); $form = Form::factory()->create(); // creating a text form $response = $this->authRequest( 'get', route('form.show', $form) ); } public function test_update() { // deleting existing forms Form::query()->delete(); $form = Form::factory()->create(); $response = $this->authRequest( 'put', route('form.update', $form), JsonResponse::HTTP_OK, Form::factory()->request()->make()->toArray() ); } public function test_destroy() { // deleting existing forms Form::query()->delete(); $form = Form::factory()->create(); // creating a text form $response = $this->authRequest( 'delete', route('form.destroy', $form), JsonResponse::HTTP_NO_CONTENT ); } public function test_destroy_many() { // deleting existing forms Form::query()->delete(); $forms = Form::factory(3)->create(); // creating a text form $response = $this->authRequest( 'post', route('form.destroyMany'), JsonResponse::HTTP_NO_CONTENT, [ 'forms' => $forms->pluck('id')->toArray() ] ); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.19 |
proxy
|
phpinfo
|
Settings