aboutsummaryrefslogtreecommitdiffstats
path: root/lib/t
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-02-25 14:45:20 +0000
committerRomain d'Alverny <rda@mageia.org>2012-02-25 14:45:20 +0000
commit67c36ffe4bd35b887c40e348e7d774d9e6a012ae (patch)
treee12b52b5f021d19a9463d87cd3732cea9d6a60bb /lib/t
parente30812f093ad07458cf978ed7402cae54713152e (diff)
downloadwww-67c36ffe4bd35b887c40e348e7d774d9e6a012ae.tar
www-67c36ffe4bd35b887c40e348e7d774d9e6a012ae.tar.gz
www-67c36ffe4bd35b887c40e348e7d774d9e6a012ae.tar.bz2
www-67c36ffe4bd35b887c40e348e7d774d9e6a012ae.tar.xz
www-67c36ffe4bd35b887c40e348e7d774d9e6a012ae.zip
tests for mga_geoip and downloads
Diffstat (limited to 'lib/t')
-rw-r--r--lib/t/00_downloads.t40
-rw-r--r--lib/t/01_mga_geoip.t28
2 files changed, 68 insertions, 0 deletions
diff --git a/lib/t/00_downloads.t b/lib/t/00_downloads.t
new file mode 100644
index 000000000..f30f9bf51
--- /dev/null
+++ b/lib/t/00_downloads.t
@@ -0,0 +1,40 @@
+<?php
+
+
+require realpath(__DIR__ . '/../testmore.php');
+require realpath(__DIR__ . '/../Downloads.php');
+
+plan('no_plan');
+
+diag('Testing prepare_download(). Countries/continents should match.');
+
+$wsd = new Downloads();
+
+$countries = array(
+ 'FR' => array('FR', 'EU'),
+ 'DE' => array('DE', 'EU'),
+ 'AU' => array('AU', 'OC')
+);
+
+foreach ($countries as $k => $v) {
+ $one = $wsd->prepare_download(true, $k);
+
+ //is($one['country'], $v[0], "countries match");
+ is($one['continent'], $v[1], "continents match");
+}
+
+diag('Testing get_mirror(). Note, this depends on the actual mirrors list.');
+
+$ccs = array(
+ array('FR', 'EU'),
+ array('DE', 'EU'),
+ array('CN', 'AS')
+);
+
+foreach ($ccs as $cc) {
+ $mir = $wsd->get_mirror($cc[0], $cc[1]);
+
+ //is($mir['country'], $cc[0], 'country match');
+ is($mir['continent'], $cc[1], 'continents match');
+}
+
diff --git a/lib/t/01_mga_geoip.t b/lib/t/01_mga_geoip.t
new file mode 100644
index 000000000..a33a708a7
--- /dev/null
+++ b/lib/t/01_mga_geoip.t
@@ -0,0 +1,28 @@
+<?php
+
+require_once realpath(__DIR__ . '/../testmore.php');
+require_once realpath(__DIR__ . '/../mga_geoip.php');
+
+plan('no_plan');
+
+diag('Testing mga_geoip_* functions against defined IP/locations.');
+
+$ips = array(
+ '2a01:e35:8a03:9990:223:dfff:fe7e:e7f0'
+ => array('FR', 'EU'),
+
+ '2a00:1450:8006::93'
+ => array('IE', 'EU'),
+
+ '173.194.67.99'
+ => array('US', 'NA'),
+
+ '46.33.75.17'
+ => array('DE', 'EU')
+);
+
+foreach ($ips as $ip => $cc) {
+ is($country = mga_geoip_country_by_ip($ip, false), $cc[0], 'country match for ' . $ip);
+ is(mga_geoip_continent_by_country($country), $cc[1], 'continent match for ' . $ip);
+}
+