public function getIsoCodeFromIpAddress($ipAddress) { if ($this->userId == '') { return null; } if ($ipAddress == '127.0.0.1') { return null; } // @codeCoverageIgnoreStart $client = new Client($this->userId, $this->licenseKey); $model = $client->country($ipAddress); $isoCode = $model->country->isoCode; return $isoCode; // @codeCoverageIgnoreEnd }
public function testParams() { $plugin = new MockPlugin(); $plugin->addResponse($this->getResponse('1.2.3.4')); $guzzleClient = new GuzzleClient(); $guzzleClient->addSubscriber($plugin); $client = new Client(42, 'abcdef123456', array('en'), 'geoip.maxmind.com', $guzzleClient); $client->country('1.2.3.4'); $all_requests = $plugin->getReceivedRequests(); $request = $all_requests[0]; $this->assertEquals('https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.4', $request->getUrl(), 'got expected URI for Country request'); $this->assertEquals('GET', $request->getMethod(), 'request is a GET'); $this->assertEquals('application/json', $request->getHeader('Accept'), 'request sets Accept header to application/json'); $this->assertStringMatchesFormat('GeoIP2 PHP API (Guzzle%s)', $request->getHeader('User-Agent') . '', 'request sets Accept header to application/json'); }