Exemple #1
0
 /**
  * @param string $address
  */
 private function executeQuery($address)
 {
     $uri = sprintf('file://geoip?%s', $address);
     try {
         $result = $this->adapter->setLocale($this->locale)->getContent($uri);
     } catch (AddressNotFoundException $e) {
         throw new NoResult(sprintf('No results found for IP address "%s".', $address));
     }
     return $result;
 }
 public function testReaderResponseIsJsonEncoded()
 {
     $cityModel = $this->getGeoIP2ModelMock(GeoIP2Adapter::GEOIP2_MODEL_CITY);
     $geoIp2Provider = $this->getGeoIP2ProviderMock();
     $geoIp2Provider->expects($this->any())->method('city')->will($this->returnValue($cityModel));
     $adapter = new GeoIP2Adapter($geoIp2Provider);
     $result = $adapter->getContent('file://database?127.0.0.1');
     $this->assertJson($result);
     $decodedResult = json_decode($result);
     $this->assertObjectHasAttribute('city', $decodedResult);
 }