public function GeoLocatorPluginTest::testCdn in GeoIP API 8.2
Tests the CDN plugin.
File
- tests/
src/ Kernel/ GeoLocatorPluginTest.php, line 30
Class
- GeoLocatorPluginTest
- Tests the default GeoLocator plugins.
Namespace
Drupal\Tests\geoip\KernelCode
public function testCdn() {
$this
->config('geoip.geolocation')
->set('plugin_id', 'cdn')
->save();
$_SERVER['HTTP_CF_IPCOUNTRY'] = 'US';
$this
->assertEquals('US', $this->container
->get('geoip.geolocation')
->geolocate('127.0.0.1'));
unset($_SERVER['HTTP_CF_IPCOUNTRY']);
$_SERVER['HTTP_CLOUDFRONT_VIEWER_COUNTRY'] = 'CA';
$this
->assertEquals('CA', $this->container
->get('geoip.geolocation')
->geolocate('192.168.1.1'));
}