diff options
Diffstat (limited to 'tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php')
-rw-r--r-- | tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php index 6c7cde409a..d687709eb9 100644 --- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php +++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php @@ -9,8 +9,9 @@ namespace Piwik\Tests\Fixtures; use Piwik\Cache; use Piwik\Date; +use Piwik\Option; use Piwik\Plugins\Goals\API; -use Piwik\Plugins\UserCountry\LocationProvider\GeoIp; +use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2; use Piwik\Plugins\UserCountry\LocationProvider; use Piwik\Tests\Framework\Fixture; use Exception; @@ -25,7 +26,7 @@ require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Framework/Mock/LocationProvide */ class ManyVisitsWithGeoIP extends Fixture { - const GEOIP_IMPL_TO_TEST = 'geoip_php'; + const GEOIP_IMPL_TO_TEST = 'geoip2php'; public $idSite = 1; public $dateTime = '2010-01-03 11:22:33'; @@ -35,10 +36,10 @@ class ManyVisitsWithGeoIP extends Fixture '::ffff:137.82.130.49', // in British Columbia (mapped ipv4) '137.82.130.0', // anonymization tests '137.82.0.0', - '2001:db8:85a3:0:0:8a2e:370:7334', // ipv6 + '2003:f6:93bf:26f:9ec7:a6ff:fe29:27df', // ipv6 in US (without region or city) '113.62.1.1', // in Lhasa, Tibet '151.100.101.92', // in Rome, Italy (using country DB, so only Italy will show) - '103.29.196.229', // in Indonesia (Bali), (only Indonesia will show up) + '103.29.196.229', // in Indonesia, Central Java (Bali) ); public $userAgents = array( @@ -57,22 +58,24 @@ class ManyVisitsWithGeoIP extends Fixture public function setUp() { + // set option, so tracked data for the past won't get converted + Option::set(GeoIp2::SWITCH_TO_ISO_REGIONS_OPTION_NAME, 1); + $this->setUpWebsitesAndGoals(); - self::downloadGeoIpDbs(); $this->setMockLocationProvider(); $this->trackVisits(9, false); - $this->setLocationProvider('GeoIPCity.dat'); + $this->setLocationProvider('GeoIP2-City.mmdb'); $this->trackVisits(2, true, $useLocal = false); $this->trackVisits(4, true, $useLocal = false, $doBulk = true); - $this->setLocationProvider('GeoIP.dat'); + $this->setLocationProvider('GeoIP2-Country.mmdb'); $this->trackVisits(2, true); $this->trackOtherVisits(); - $this->setLocationProvider('GeoIPCity.dat'); + $this->setLocationProvider('GeoIP2-City.mmdb'); } public function tearDown() @@ -240,8 +243,8 @@ class ManyVisitsWithGeoIP extends Fixture public function setLocationProvider($file) { - GeoIp::$dbNames['loc'] = array($file); - GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; + GeoIp2::$dbNames['loc'] = array($file); + GeoIp2::$geoIPDatabaseDir = 'tests/lib/geoip-files'; LocationProvider::$providers = null; LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST); @@ -249,9 +252,9 @@ class ManyVisitsWithGeoIP extends Fixture throw new Exception("Failed to set the current location provider to '" . self::GEOIP_IMPL_TO_TEST . "'."); } - $possibleFiles = GeoIp::$dbNames['loc']; - if (GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) { - throw new Exception("The GeoIP location provider cannot find the '$file' file! Tests will fail."); + $possibleFiles = GeoIp2::$dbNames['loc']; + if (GeoIp2::getPathToGeoIpDatabase($possibleFiles) === false) { + throw new Exception("The GeoIP2 location provider cannot find the '$file' file! Tests will fail."); } } @@ -261,28 +264,28 @@ class ManyVisitsWithGeoIP extends Fixture LocationProvider::$providers[] = new MockLocationProvider(); LocationProvider::setCurrentProvider('mock_provider'); MockLocationProvider::$locations = array( - self::makeLocation('Stratford-upon-Avon', 'P3', 'gb', 123.456, 21.321), // template location + self::makeLocation('Stratford-upon-Avon', 'WAR', 'gb', 123.456, 21.321), // template location // same region, different city, same country - self::makeLocation('Nuneaton and Bedworth', 'P3', 'gb', $isp = 'comcast.net'), + self::makeLocation('Nuneaton and Bedworth', 'WAR', 'gb', $isp = 'comcast.net'), // same region, city & country (different lat/long) - self::makeLocation('Stratford-upon-Avon', 'P3', 'gb', 124.456, 22.231, $isp = 'comcast.net'), + self::makeLocation('Stratford-upon-Avon', 'WAR', 'gb', 124.456, 22.231, $isp = 'comcast.net'), // same country, different region & city - self::makeLocation('London', 'H9', 'gb'), + self::makeLocation('London', 'LND', 'gb'), // same country, different region, same city - self::makeLocation('Stratford-upon-Avon', 'G5', 'gb', $lat = null, $long = null, $isp = 'awesomeisp.com'), + self::makeLocation('Stratford-upon-Avon', 'KEN', 'gb', $lat = null, $long = null, $isp = 'awesomeisp.com'), // different country, diff region, same city - self::makeLocation('Stratford-upon-Avon', '66', 'ru'), + self::makeLocation('Stratford-upon-Avon', 'SPE', 'ru'), // different country, diff region (same as last), different city - self::makeLocation('Hluboká nad Vltavou', '66', 'ru'), + self::makeLocation('Hluboká nad Vltavou', 'SPE', 'ru'), // different country, diff region (same as last), same city - self::makeLocation('Stratford-upon-Avon', '66', 'mk'), + self::makeLocation('Stratford-upon-Avon', '18', 'mk'), // unknown location self::makeLocation(null, null, null), @@ -297,4 +300,4 @@ class ManyVisitsWithGeoIP extends Fixture // ignore error } } -} +}
\ No newline at end of file |