Advertisement
Guest User

Untitled

a guest
Jul 13th, 2020
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. /**
  2.  * @group api-map
  3.  */
  4. public function test_generate_route()
  5. {
  6.     $car = Car::find(1);
  7.     $apiCarCode = Str::limit($car->api_code, 10, '') . '_' . $car->id;
  8.  
  9.     $apiDataStartPoint = [
  10.         'latitude'    => 51.53,
  11.         'longitude'   => 43.54,
  12.         'carInfo'     => $apiCarCode,
  13.         'start_route' => 1,
  14.         'end_route'   => 0,
  15.     ];
  16.     $apiDataMiddlePoint = [
  17.         'latitude'    => 51.71,
  18.         'longitude'   => 43.74,
  19.         'carInfo'     => $apiCarCode,
  20.         'start_route' => 0,
  21.         'end_route'   => 0,
  22.     ];
  23.     $apiDataEndPoint = [
  24.         'latitude'    => 51.9,
  25.         'longitude'   => 43.94,
  26.         'carInfo'     => $apiCarCode,
  27.         'start_route' => 0,
  28.         'end_route'   => 1,
  29.     ];
  30.  
  31.     $apiDataNewRoute = [
  32.         'latitude'    => 150.9,
  33.         'longitude'   => 70.94,
  34.         'carInfo'     => $apiCarCode,
  35.         'start_route' => 1,
  36.         'end_route'   => 0,
  37.     ];
  38.  
  39.     $this
  40.         ->post(route('api.gps', $apiDataStartPoint))
  41.         ->assertStatus(200);
  42.  
  43.     $this
  44.         ->post(route('api.gps', $apiDataMiddlePoint))
  45.         ->assertStatus(200);
  46.  
  47.     $this
  48.         ->post(route('api.gps', $apiDataEndPoint))
  49.         ->assertStatus(200);
  50.  
  51.     sleep(1);
  52.  
  53.     $this
  54.         ->post(route('api.gps', $apiDataNewRoute))
  55.         ->assertStatus(200);
  56.  
  57.  
  58.     $this
  59.         ->assertDatabaseHas('cars_points', [
  60.             'id'        => 1,
  61.             'car_id'    => $car->id,
  62.             'route_id'  => 1,
  63.             'latitude'  => $apiDataStartPoint['latitude'],
  64.             'longitude' => $apiDataStartPoint['longitude']
  65.         ])
  66.         ->assertDatabaseHas('cars_points', [
  67.             'id'        => 2,
  68.             'car_id'    => $car->id,
  69.             'route_id'  => 1,
  70.             'latitude'  => $apiDataMiddlePoint['latitude'],
  71.             'longitude' => $apiDataMiddlePoint['longitude']
  72.         ])
  73.         ->assertDatabaseHas('cars_points', [
  74.             'id'        => 3,
  75.             'car_id'    => $car->id,
  76.             'route_id'  => 1,
  77.             'latitude'  => $apiDataEndPoint['latitude'],
  78.             'longitude' => $apiDataEndPoint['longitude']
  79.         ])
  80.         ->assertDatabaseHas('cars_routes', [
  81.             'id'     => 1,
  82.             'car_id' => $car->id,
  83.         ])
  84.         ->assertDatabaseHas('cars_routes', [
  85.             'id'     => 2,
  86.             'car_id' => $car->id,
  87.         ])
  88.         ->assertDatabaseCount('cars_route_sections', 2)
  89.         ->assertDatabaseCount('cars_routes', 2);
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement