1
+ <?php
2
+ /**
3
+ * Matomo - free/libre analytics platform
4
+ *
5
+ * @link https://matomo.org
6
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7
+ */
8
+
9
+ namespace Piwik \Plugins \UserCountry \tests \Integration ;
10
+
11
+ use Piwik \Plugins \GeoIp2 \LocationProvider \GeoIp2 \Php ;
12
+ use Piwik \Plugins \GeoIp2 \LocationProvider \GeoIp2 \ServerModule ;
13
+ use Piwik \Plugins \UserCountry \LocationProvider ;
14
+ use Piwik \Tests \Framework \TestCase \IntegrationTestCase ;
15
+
16
+ /**
17
+ * @group UserCountry
18
+ * @group LocationProvider
19
+ */
20
+ class LocationProviderTest extends IntegrationTestCase
21
+ {
22
+ public function testGetAllProviderInfo ()
23
+ {
24
+ $ allProviders = LocationProvider::getAllProviderInfo ();
25
+
26
+ // We currently have 3 Providers shipped with core
27
+ $ this ->assertSame (3 , count ($ allProviders ));
28
+ $ this ->assertEquals (['default ' , 'geoip2php ' , 'geoip2server ' ], array_keys ($ allProviders ));
29
+ }
30
+
31
+ public function testGetAllProviderInfoWithDuplicateOrder ()
32
+ {
33
+ \Piwik \Tests \Framework \Mock \LocationProvider::$ locations = [
34
+ [
35
+ LocationProvider::CITY_NAME_KEY => 'Manchaster ' ,
36
+ LocationProvider::REGION_CODE_KEY => '15 ' ,
37
+ LocationProvider::COUNTRY_CODE_KEY => 'US ' ,
38
+ LocationProvider::LATITUDE_KEY => '12 ' ,
39
+ LocationProvider::LONGITUDE_KEY => '11 ' ,
40
+ LocationProvider::ISP_KEY => 'Facebook ' ,
41
+ ],
42
+ ];
43
+
44
+ LocationProvider::$ providers = [
45
+ new LocationProvider \DefaultProvider (),
46
+ new Php (),
47
+ new ServerModule (),
48
+ new \Piwik \Tests \Framework \Mock \LocationProvider (),
49
+ ];
50
+
51
+ $ allProviders = LocationProvider::getAllProviderInfo ();
52
+
53
+ $ this ->assertSame (4 , count ($ allProviders ));
54
+ $ this ->assertEquals (['default ' , 'geoip2php ' , 'mock_provider ' , 'geoip2server ' ], array_keys ($ allProviders ));
55
+ }
56
+ }
0 commit comments