File manager - Edit - /var/www/html/spdc/api/tests/Feature/ScheduleTest.php
Back
<?php namespace Tests\Feature; use Tests\BaseTest; use App\Models\User; use App\Models\Schedule; use App\Models\Occurrency; use App\Enums\ScheduleType; use App\Models\Transportation; use Illuminate\Http\JsonResponse; use AluisioPires\LaravelBaseTest\BaseTestTransactions; class ScheduleTest extends BaseTest { // public function test_index() // { // // deleting existing departments // Schedule::query()->delete(); // // creating two departments // Schedule::factory(2)->create(); // $response = $this->authRequest( // 'get', // route('schedule.index'), // JsonResponse::HTTP_OK // ); // $response->assertJsonCount(2, 'data.data'); // } // public function test_index_with_filters() // { // $vehicleCategories = getEnumValuesToArray(\App\Enums\VehicleCategory::cases()); // $randomCategory = $vehicleCategories[array_rand($vehicleCategories)]; // // deleting existing departments // Schedule::query()->delete(); // // creating two departments // $schedules = Schedule::factory(6)->create(); // $count = $schedules->where('category', $randomCategory)->count(); // $response = $this->authRequest( // 'get', // route('schedule.index', [ // 'category' => $randomCategory // ]), // JsonResponse::HTTP_OK // ); // $response->assertJsonCount($count, 'data.data'); // } // public function test_index_with_search() // { // $vehicleCategories = getEnumValuesToArray(\App\Enums\VehicleCategory::cases()); // $randomCategory = $vehicleCategories[array_rand($vehicleCategories)]; // // deleting existing departments // Schedule::query()->delete(); // // creating two departments // $schedules = Schedule::factory(6)->state(['category' => $randomCategory])->create(); // do { // $searchTerm = substr($schedules[0]->model, 0, 3); // } while (strlen($schedules[0]->model) < 3); // $response = $this->authRequest( // 'get', // route('schedule.index', [ // 'category' => $randomCategory, // 'search_term' => $searchTerm // ]), // JsonResponse::HTTP_OK // ); // } public function test_store_default() { // deleting existing departments Schedule::query()->delete(); $transportation = Transportation::factory()->create(); $occurencies = Occurrency::factory(3)->create(); // creating a text schedule $response = $this->authRequest( 'post', route('schedule.store'), JsonResponse::HTTP_CREATED, [ 'type' => ScheduleType::PADRAO->value, 'date' => fake()->date, 'exit_time' => fake()->time('H:i'), 'driver_id' => env('USER_ID'), 'note' => fake()->words(3, true), 'emergency' => false, 'transportation_id' => $transportation->id, 'agents' => [ 'id', 'id' ], 'occurrencies' => $occurencies->pluck('id')->toArray() ] ); dd($response->json()); } public function test_store_extra() { // deleting existing departments Schedule::query()->delete(); $user = User::factory()->create(); $transportation = Transportation::factory()->create(); $agents = User::factory(4)->create(); // creating a text schedule $response = $this->authRequest( 'post', route('schedule.store'), JsonResponse::HTTP_CREATED, [ 'type' => ScheduleType::EXTRA->value, 'date' => fake()->date, 'exit_time' => fake()->time('H:i'), 'driver_id' => $user->id, 'note' => fake()->words(3, true), 'emergency' => false, 'transportation_id' => $transportation->id, 'agents' => $agents->pluck('id')->toArray(), 'name' => fake()->unique->word, ] ); } public function test_show_default() { // deleting existing departments Schedule::query()->delete(); $schedule = Schedule::factory()->defaultType()->create(); // creating a text schedule $response = $this->authRequest( 'get', route('schedule.show', $schedule) ); } public function test_show_extra() { // deleting existing departments Schedule::query()->delete(); $schedule = Schedule::factory()->extraType()->create(); // creating a text schedule $response = $this->authRequest( 'get', route('schedule.show', $schedule) ); } // public function test_update() // { // // deleting existing departments // Schedule::query()->delete(); // $schedule = Schedule::factory()->create(); // $response = $this->authRequest( // 'put', // route('schedule.update', $schedule), // JsonResponse::HTTP_OK, // Schedule::factory()->make()->toArray() // ); // // dump($response->json()); // } // public function test_destroy_many() // { // // deleting existing fields // Schedule::query()->delete(); // $schedules = Schedule::factory(5)->create(); // // creating a text field // $response = $this->authRequest( // 'post', // route('schedule.destroyMany'), // JsonResponse::HTTP_NO_CONTENT, // [ // 'schedules' => $schedules->pluck('id')->toArray() // ] // ); // } // public function test_update_status() // { // // deleting existing departments // Schedule::query()->delete(); // $schedule = Schedule::factory()->create(); // $response = $this->authRequest( // 'post', // route('schedule.updateStatus', $schedule), // JsonResponse::HTTP_OK, // [ // 'status' => 'Operante' // ] // ); // dump($response->json()); // } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.14 |
proxy
|
phpinfo
|
Settings