Advertisement
Guest User

Untitled

a guest
Jul 13th, 2020
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. public function test_generate_route()
  2. {
  3. Queue::fake();
  4.  
  5. $car = Car::find(1);
  6. $apiCarCode = Str::limit($car->api_code, 10, '') . '_' . $car->id;
  7.  
  8. $apiDataStartPoint = [
  9. 'latitude' => 51.53,
  10. 'longitude' => 43.54,
  11. 'carInfo' => $apiCarCode,
  12. 'start_route' => 1,
  13. 'end_route' => 0,
  14. ];
  15. $apiDataMiddlePoint = [
  16. 'latitude' => 51.71,
  17. 'longitude' => 43.74,
  18. 'carInfo' => $apiCarCode,
  19. 'start_route' => 0,
  20. 'end_route' => 0,
  21. ];
  22. $apiDataEndPoint = [
  23. 'latitude' => 51.9,
  24. 'longitude' => 43.94,
  25. 'carInfo' => $apiCarCode,
  26. 'start_route' => 0,
  27. 'end_route' => 1,
  28. ];
  29.  
  30. $apiDataNewRoute = [
  31. 'latitude' => 150.9,
  32. 'longitude' => 70.94,
  33. 'carInfo' => $apiCarCode,
  34. 'start_route' => 1,
  35. 'end_route' => 0,
  36. ];
  37.  
  38. $this
  39. ->post(route('api.gps', $apiDataStartPoint))
  40. ->assertStatus(200);
  41. Queue::assertPushed(GenerateRouteJob::class);
  42.  
  43. $this
  44. ->post(route('api.gps', $apiDataMiddlePoint))
  45. ->assertStatus(200);
  46. Queue::assertPushed(GenerateRouteJob::class);
  47.  
  48. $this
  49. ->post(route('api.gps', $apiDataEndPoint))
  50. ->assertStatus(200);
  51. Queue::assertPushed(GenerateRouteJob::class);
  52.  
  53. $this
  54. ->post(route('api.gps', $apiDataNewRoute))
  55. ->assertStatus(200);
  56. Queue::assertPushed(GenerateRouteJob::class);
  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