Files
backend/tests/Feature/V2/Dashboard/RoadPatrolProject/GetAllDataToMapTest.php

95 lines
3.4 KiB
PHP

<?php
namespace Tests\Feature\V2\Dashboard\RoadPatrolProject;
use App\Models\Province;
use App\Models\RoadPatrol;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Tests\TestCase;
class GetAllDataToMapTest extends TestCase
{
use DatabaseTruncation;
/**
* A basic feature test example.
*/
public function test_all_data_can_be_seen_with_no_filter(): void
{
$user = User::factory()->create();
RoadPatrol::factory()
->sequence(
['id' => 1],
['id' => 2],
['id' => 3],
['id' => 4],
['id' => 5],
['id' => 6],
['id' => 7],
)
->count(7)
->create();
$response = $this->actingAs($user)->getJson('/v2/road_patrols/report/map');
$response->assertStatus(200)
->assertExactJson([
'status' => 'succeed',
'count' => 7,
'message' => '',
'data' => [
["id" => 1, "start_lat" => 0, "start_lon" => 0],
["id" => 2, "start_lat" => 0, "start_lon" => 0],
["id" => 3, "start_lat" => 0, "start_lon" => 0],
["id" => 4, "start_lat" => 0, "start_lon" => 0],
["id" => 5, "start_lat" => 0, "start_lon" => 0],
["id" => 6, "start_lat" => 0, "start_lon" => 0],
["id" => 7, "start_lat" => 0, "start_lon" => 0],
]
]);
}
public function test_all_data_can_be_seen_with_filter(): void
{
$user = User::factory()->create();
$province = Province::factory()->create();
RoadPatrol::factory()
->sequence(
["id" => 1, 'created_at' => '2022-05-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 1],
["id" => 2, 'created_at' => '2025-05-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 5],
["id" => 3, 'created_at' => '2022-05-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 9],
["id" => 4, 'created_at' => '2026-05-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 2],
["id" => 5, 'created_at' => '2022-05-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 6],
["id" => 6, 'created_at' => '2026-08-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 16],
["id" => 7, 'created_at' => '2022-05-03 12:25:00', 'province_id' => $province->id, 'edare_id' => 35],
)
->count(7)
->create();
// $response = $this->actingAs($user)->getJson(route('v2.road_patrols.report.map', [
// 'date_from' => '2021-05-02',
// 'date_to' => '2024-09-01',
// 'province_id' => 1,
// 'edare_id' => 1,
// ]));
$response = $this->actingAs($user)->getJson('/v2/road_patrols/report/map?date_from=2021-05-02&date_to=2024-09-01&province_id=1&edare_id=1');
$response->assertStatus(200)
->assertExactJson([
'status' => 'succeed',
'count' => 1,
'message' => '',
'data' => [
[
"id" => 1,
"start_lat" => 0,
"start_lon" => 0
]
]
]);
}
}