File manager - Edit - /var/www/html/spdc/api/tests/Feature/DepartmentTest.php
Back
<?php namespace Tests\Feature; use Tests\BaseTest; use App\Models\Form; use App\Models\Field; use App\Models\Department; use Illuminate\Http\JsonResponse; use App\Enums\OccurrencyScriptureType; use AluisioPires\LaravelBaseTest\BaseTestTransactions; class DepartmentTest extends BaseTest { public function test_index() { // deleting existing departments Department::query()->delete(); // creating two departments Department::factory(2)->create(); $response = $this->authRequest( 'get', route('department.index'), JsonResponse::HTTP_OK ); $response->assertJsonCount(2, 'data.data'); // dump($response->json()); } public function test_store() { // deleting existing departments Department::query()->delete(); // creating a text department $response = $this->authRequest( 'post', route('department.store'), JsonResponse::HTTP_CREATED, Department::factory()->make()->toArray() ); // dump($response->json()); } public function test_show() { // deleting existing departments Department::query()->delete(); $department = Department::factory()->create(); // creating a text department $response = $this->authRequest( 'get', route('department.show', $department) ); // dump($response->json()); } public function test_update() { // deleting existing departments Department::query()->delete(); $department = Department::factory()->create(); $response = $this->authRequest( 'put', route('department.update', $department), JsonResponse::HTTP_OK, Department::factory()->make()->toArray() ); // dump($response->json()); } public function test_disable() { // deleting existing departments Department::query()->delete(); $departments = Department::factory(3)->create(); // creating a text department $response = $this->authRequest( 'post', route('department.disable'), JsonResponse::HTTP_NO_CONTENT, [ 'departments' => $departments->pluck('id')->toArray() ] ); // dump(Department::all()->toArray()); } public function test_enable() { // deleting existing departments Department::query()->delete(); $departments = Department::factory(3)->state(['enable' => 0])->create(); // creating a text department $response = $this->authRequest( 'post', route('department.enable'), JsonResponse::HTTP_NO_CONTENT, [ 'departments' => $departments->pluck('id')->toArray() ] ); // dump(Department::all()->toArray()); } public function test_destroy_many() { // deleting existing fields Department::query()->delete(); $departments = Department::factory(5)->create(); // creating a text field $response = $this->authRequest( 'post', route('department.destroyMany'), JsonResponse::HTTP_NO_CONTENT, [ 'departments' => $departments->pluck('id')->toArray() ] ); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings