GpsCoordinateTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Tests\Application\Utils;
  3. use App\Tests\Application\OtWebTestCase;
  4. class GpsCoordinateTest extends OtWebTestCase
  5. {
  6. public function testGetGpsCoordinateReverse(): void
  7. {
  8. $this->loginAs($this->user);
  9. $this->assertResponseIsSuccessful();
  10. $this->get('/api/gps-coordinate-reverse/48.8566/2.3522');
  11. $this->assertResponseStatusCodeSame(200);
  12. $this->assertJsonContains([
  13. '@context' => '/api/contexts/GpsCoordinate',
  14. '@id' => '/api/gps-coordinate-reverse/48.8564263/2.3525275780116',
  15. '@type' => 'GpsCoordinate',
  16. 'latitude' => 48.856426299999995,
  17. 'longitude' => 2.3525275780116073,
  18. 'streetAddress' => "Place de l'Hôtel de Ville",
  19. 'streetAddressSecond' => null,
  20. 'streetAddressThird' => null,
  21. 'cp' => "75004",
  22. 'city' => null,
  23. 'country' => null
  24. ]);
  25. }
  26. public function testGetGpsCoordinateSearching()
  27. {
  28. $this->loginAs($this->user);
  29. $this->assertResponseIsSuccessful();
  30. $this->get('/api/gps-coordinate-searching');
  31. $this->assertResponseStatusCodeSame(200);
  32. $this->assertJsonContains([
  33. '@context' => '/api/contexts/GpsCoordinate',
  34. '@id' => '/api/gps-coordinate-searching',
  35. '@type' => 'hydra:Collection',
  36. 'hydra:totalItems' => 1,
  37. 'hydra:member' => [
  38. [
  39. '@id' => '/api/gps-coordinate-reverse/0/0',
  40. '@type' => 'GpsCoordinate',
  41. 'latitude' => 0,
  42. 'longitude' => 0,
  43. 'streetAddress' => null,
  44. 'streetAddressSecond' => null,
  45. 'streetAddressThird' => null,
  46. 'cp' => null,
  47. 'city' => null,
  48. 'country' => null
  49. ]
  50. ]
  51. ]);
  52. }
  53. public function testGetGpsCoordinateReverseWithInvalidCoordinates(): void
  54. {
  55. $this->loginAs($this->user);
  56. $this->get('/api/gps-coordinate-reverse/12345.6789/98765.4321');
  57. $this->assertResponseStatusCodeSame(404);
  58. $this->assertJsonContains([
  59. '@context' => '/api/contexts/Error',
  60. '@type' => 'hydra:Error',
  61. 'hydra:title' => 'An error occurred',
  62. 'hydra:description' => 'Failed to retrieve GPS coordinates: No address found for the given GPS coordinates.',
  63. ]);
  64. }
  65. }