Skip to content

Commit 5c1ec28

Browse files
authored
Make sure "NoResult" is giving a good response (#4)
* Make sure "NoResult" is giving a good response * Updated for latest changes in Geocoder/Common * Minor fixes
1 parent 95e611e commit 5c1ec28

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/ProviderIntegrationTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use Geocoder\Model\Bounds;
1717
use Geocoder\Model\Coordinates;
1818
use Geocoder\Model\Country;
19-
use Geocoder\Model\Query\GeocodeQuery;
20-
use Geocoder\Model\Query\ReverseQuery;
2119
use Geocoder\Provider\Provider;
20+
use Geocoder\Query\GeocodeQuery;
21+
use Geocoder\Query\ReverseQuery;
2222
use GuzzleHttp\Psr7\Response;
2323
use Http\Client\HttpClient;
2424
use Http\Discovery\HttpClientDiscovery;
@@ -97,6 +97,19 @@ public function testGeocodeQuery()
9797
$this->assertContains('10', $location->getStreetNumber(), 'Street number should contain "10"');
9898
}
9999

100+
public function testGeocodeQueryWithNoResults()
101+
{
102+
if (isset($this->skippedTests[__FUNCTION__])) {
103+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
104+
}
105+
106+
$provider = $this->createProvider($this->getCachedHttpClient());
107+
$query = GeocodeQuery::create('jsajhgsdkfjhsfkjhaldkadjaslgldasd')->withLocale('en');
108+
$result = $provider->geocodeQuery($query);
109+
$this->assertWellFormattedResult($result);
110+
$this->assertEquals(0, $result->count());
111+
}
112+
100113
public function testReverseQuery()
101114
{
102115
if (isset($this->skippedTests[__FUNCTION__])) {
@@ -292,8 +305,6 @@ private function assertWellFormattedResult(Collection $result)
292305
'The result must be an instance of a Geocoder\Collection'
293306
);
294307

295-
$this->assertNotEmpty($result, 'Geocoder\Exception should never be empty. A NoResult exception should be thrown.');
296-
297308
/** @var Location $location */
298309
foreach ($result as $location) {
299310
$this->assertInstanceOf(

0 commit comments

Comments
 (0)