/** * @return bool|int */ public function getId() { $id = $this->getIdFromSignedCookie(); if (false === $id) { $ipAddress = $this->request->getClientIp(); $geocoderResult = null; if ($this->geocoder) { try { $geocoderResult = $this->geocoder->geocode($ipAddress)->first(); } catch (NoResultException $e) { } } $id = $this->dbGateway->insertUserInformation($ipAddress, $_SERVER['HTTP_USER_AGENT'], php_sapi_name(), $geocoderResult); $this->writeSignedCookie($id); } return $id; }
/** * @expectedException \Geocoder\Exception\NoResult * @expectedExceptionMessage No results found for IP address 74.200.247.59 */ public function testRetrievingGeodataNotExistingLocation() { $adapterReturn = new NoResult('No results found for IP address 74.200.247.59'); $adapter = $this->getGeoIP2AdapterMock($adapterReturn); $provider = new GeoIP2($adapter); $provider->geocode('74.200.247.59'); }