Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @group api-map
- */
- public function test_generate_route()
- {
- $car = Car::find(1);
- $apiCarCode = Str::limit($car->api_code, 10, '') . '_' . $car->id;
- $apiDataStartPoint = [
- 'latitude' => 51.53,
- 'longitude' => 43.54,
- 'carInfo' => $apiCarCode,
- 'start_route' => 1,
- 'end_route' => 0,
- ];
- $apiDataMiddlePoint = [
- 'latitude' => 51.71,
- 'longitude' => 43.74,
- 'carInfo' => $apiCarCode,
- 'start_route' => 0,
- 'end_route' => 0,
- ];
- $apiDataEndPoint = [
- 'latitude' => 51.9,
- 'longitude' => 43.94,
- 'carInfo' => $apiCarCode,
- 'start_route' => 0,
- 'end_route' => 1,
- ];
- $apiDataNewRoute = [
- 'latitude' => 150.9,
- 'longitude' => 70.94,
- 'carInfo' => $apiCarCode,
- 'start_route' => 1,
- 'end_route' => 0,
- ];
- $this
- ->post(route('api.gps', $apiDataStartPoint))
- ->assertStatus(200);
- $this
- ->post(route('api.gps', $apiDataMiddlePoint))
- ->assertStatus(200);
- $this
- ->post(route('api.gps', $apiDataEndPoint))
- ->assertStatus(200);
- sleep(1);
- $this
- ->post(route('api.gps', $apiDataNewRoute))
- ->assertStatus(200);
- $this
- ->assertDatabaseHas('cars_points', [
- 'id' => 1,
- 'car_id' => $car->id,
- 'route_id' => 1,
- 'latitude' => $apiDataStartPoint['latitude'],
- 'longitude' => $apiDataStartPoint['longitude']
- ])
- ->assertDatabaseHas('cars_points', [
- 'id' => 2,
- 'car_id' => $car->id,
- 'route_id' => 1,
- 'latitude' => $apiDataMiddlePoint['latitude'],
- 'longitude' => $apiDataMiddlePoint['longitude']
- ])
- ->assertDatabaseHas('cars_points', [
- 'id' => 3,
- 'car_id' => $car->id,
- 'route_id' => 1,
- 'latitude' => $apiDataEndPoint['latitude'],
- 'longitude' => $apiDataEndPoint['longitude']
- ])
- ->assertDatabaseHas('cars_routes', [
- 'id' => 1,
- 'car_id' => $car->id,
- ])
- ->assertDatabaseHas('cars_routes', [
- 'id' => 2,
- 'car_id' => $car->id,
- ])
- ->assertDatabaseCount('cars_route_sections', 2)
- ->assertDatabaseCount('cars_routes', 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement