diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-08-02 00:20:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-02 00:20:40 +0300 |
commit | 8e94678be5328cf3a7aa913e1639d5c6127acfd4 (patch) | |
tree | 5b4c194608ebc2f93dcb7586aedde3df9c35424b /plugins/UserCountry/tests/Integration/LocationProviderTest.php | |
parent | 59a25a5198285cd1a5e1853abddc95b96864a801 (diff) |
Fix sorting of Geolocation providers (#17835)
* Fix sorting of Geolocation providers
* Adds some tests for provider sorting
Diffstat (limited to 'plugins/UserCountry/tests/Integration/LocationProviderTest.php')
-rw-r--r-- | plugins/UserCountry/tests/Integration/LocationProviderTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/UserCountry/tests/Integration/LocationProviderTest.php b/plugins/UserCountry/tests/Integration/LocationProviderTest.php new file mode 100644 index 0000000000..262317653f --- /dev/null +++ b/plugins/UserCountry/tests/Integration/LocationProviderTest.php @@ -0,0 +1,56 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\UserCountry\tests\Integration; + +use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2\Php; +use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2\ServerModule; +use Piwik\Plugins\UserCountry\LocationProvider; +use Piwik\Tests\Framework\TestCase\IntegrationTestCase; + +/** + * @group UserCountry + * @group LocationProvider + */ +class LocationProviderTest extends IntegrationTestCase +{ + public function testGetAllProviderInfo() + { + $allProviders = LocationProvider::getAllProviderInfo(); + + // We currently have 3 Providers shipped with core + $this->assertSame(3, count($allProviders)); + $this->assertEquals(['default', 'geoip2php', 'geoip2server'], array_keys($allProviders)); + } + + public function testGetAllProviderInfoWithDuplicateOrder() + { + \Piwik\Tests\Framework\Mock\LocationProvider::$locations = [ + [ + LocationProvider::CITY_NAME_KEY => 'Manchaster', + LocationProvider::REGION_CODE_KEY => '15', + LocationProvider::COUNTRY_CODE_KEY => 'US', + LocationProvider::LATITUDE_KEY => '12', + LocationProvider::LONGITUDE_KEY => '11', + LocationProvider::ISP_KEY => 'Facebook', + ], + ]; + + LocationProvider::$providers = [ + new LocationProvider\DefaultProvider(), + new Php(), + new ServerModule(), + new \Piwik\Tests\Framework\Mock\LocationProvider(), + ]; + + $allProviders = LocationProvider::getAllProviderInfo(); + + $this->assertSame(4, count($allProviders)); + $this->assertEquals(['default', 'geoip2php', 'mock_provider', 'geoip2server'], array_keys($allProviders)); + } +}
\ No newline at end of file |