Skip to content

Commit cdc22a1

Browse files
author
Patrick Fischer
committed
test: add LocationIQ bounds test
1 parent dc38d1c commit cdc22a1

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎src/Provider/LocationIQ/Tests/LocationIQTest.php‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Geocoder\Collection;
1616
use Geocoder\IntegrationTest\BaseTestCase;
1717
use Geocoder\Location;
18+
use Geocoder\Model\Address;
19+
use Geocoder\Model\Bounds;
1820
use Geocoder\Provider\LocationIQ\LocationIQ;
1921
use Geocoder\Query\GeocodeQuery;
2022
use Geocoder\Query\ReverseQuery;
@@ -87,4 +89,37 @@ public function testGetNodeStreetName(): void
8789
$this->assertInstanceOf(\Geocoder\Model\Address::class, $result);
8890
$this->assertEquals('Rue Quincampoix', $result->getStreetName());
8991
}
92+
93+
public function testCorrectBounds(): void
94+
{
95+
$provider = new LocationIQ($this->getHttpClient($_SERVER['LOCATIONIQ_API_KEY']), $_SERVER['LOCATIONIQ_API_KEY']);
96+
97+
$results = $provider->geocodeQuery(GeocodeQuery::create('10 Downing Street, London, United Kingdom'));
98+
99+
$this->assertInstanceOf(\Geocoder\Model\AddressCollection::class, $results);
100+
$this->assertCount(1, $results);
101+
102+
/** @var Address $result */
103+
$result = $results->first();
104+
105+
$this->assertInstanceOf(\Geocoder\Model\Address::class, $result);
106+
$this->assertEquals('Downing Street', $result->getStreetName());
107+
$this->assertEquals('United Kingdom', $result->getCountry()->getName());
108+
109+
/** @var Bounds $bounds */
110+
$bounds = $result->getBounds();
111+
112+
$north = $bounds->getNorth();
113+
$south = $bounds->getSouth();
114+
$west = $bounds->getWest();
115+
$east = $bounds->getEast();
116+
117+
$this->assertTrue($north > $south);
118+
$this->assertTrue($east > $west);
119+
120+
$this->assertEqualsWithDelta(51.5033074, $south, 1E-6);
121+
$this->assertEqualsWithDelta(51.5036913, $north, 1E-6);
122+
$this->assertEqualsWithDelta(-0.1277991, $west, 1E-6);
123+
$this->assertEqualsWithDelta(-0.1273088, $east, 1E-6);
124+
}
90125
}

0 commit comments

Comments
 (0)