| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Tests\Application\Utils;
- use App\Tests\Application\OtWebTestCase;
- class GpsCoordinateTest extends OtWebTestCase
- {
- public function testGetGpsCoordinateReverse(): void
- {
- $this->loginAs($this->user);
- $this->assertResponseIsSuccessful();
- $this->get('/api/gps-coordinate-reverse/48.8566/2.3522');
- $this->assertResponseStatusCodeSame(200);
- $this->assertJsonContains([
- '@context' => '/api/contexts/GpsCoordinate',
- '@id' => '/api/gps-coordinate-reverse/48.8564263/2.3525275780116',
- '@type' => 'GpsCoordinate',
- 'latitude' => 48.856426299999995,
- 'longitude' => 2.3525275780116073,
- 'streetAddress' => "Place de l'Hôtel de Ville",
- 'streetAddressSecond' => null,
- 'streetAddressThird' => null,
- 'cp' => "75004",
- 'city' => null,
- 'country' => null
- ]);
- }
- public function testGetGpsCoordinateSearching()
- {
- $this->loginAs($this->user);
- $this->assertResponseIsSuccessful();
- $this->get('/api/gps-coordinate-searching');
- $this->assertResponseStatusCodeSame(200);
- $this->assertJsonContains([
- '@context' => '/api/contexts/GpsCoordinate',
- '@id' => '/api/gps-coordinate-searching',
- '@type' => 'hydra:Collection',
- 'hydra:totalItems' => 1,
- 'hydra:member' => [
- [
- '@id' => '/api/gps-coordinate-reverse/0/0',
- '@type' => 'GpsCoordinate',
- 'latitude' => 0,
- 'longitude' => 0,
- 'streetAddress' => null,
- 'streetAddressSecond' => null,
- 'streetAddressThird' => null,
- 'cp' => null,
- 'city' => null,
- 'country' => null
- ]
- ]
- ]);
- }
- public function testGetGpsCoordinateReverseWithInvalidCoordinates(): void
- {
- $this->loginAs($this->user);
- $this->get('/api/gps-coordinate-reverse/12345.6789/98765.4321');
- $this->assertResponseStatusCodeSame(404);
- $this->assertJsonContains([
- '@context' => '/api/contexts/Error',
- '@type' => 'hydra:Error',
- 'hydra:title' => 'An error occurred',
- 'hydra:description' => 'Failed to retrieve GPS coordinates: No address found for the given GPS coordinates.',
- ]);
- }
- }
|