aboutsummaryrefslogtreecommitdiffstats
path: root/lib/t
diff options
context:
space:
mode:
authorThomas Backlund <tmb@mageia.org>2014-10-12 12:27:45 +0300
committerThomas Backlund <tmb@mageia.org>2014-10-12 12:27:45 +0300
commit9ce6d646ff718cd62f6434c9a4c94e450436612a (patch)
tree3ee82e5db7c0aee44a5573d9d17035c6ecac697d /lib/t
parenta0b2d09125d7911656fe4cb286f20643c4432281 (diff)
downloadwww-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.gz
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.bz2
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.tar.xz
www-9ce6d646ff718cd62f6434c9a4c94e450436612a.zip
Revert "Updated Estonian translation"
Diffstat (limited to 'lib/t')
-rw-r--r--lib/t/00_downloads.t40
-rw-r--r--lib/t/01_mga_geoip.t29
-rw-r--r--lib/t/02_downloads_definitions.t45
-rw-r--r--lib/t/03_lang_redirection.t13
4 files changed, 127 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..aa3daa674
--- /dev/null
+++ b/lib/t/01_mga_geoip.t
@@ -0,0 +1,29 @@
+<?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(
+ '46.33.75.17'
+ => array('DE', 'EU'),
+
+ '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')
+);
+
+foreach ($ips as $ip => $cc) {
+
+ $country = MGA_Geoip::mga_geoip_country_by_ip($ip, false);
+ is($country, $cc[0], 'country match for ' . $ip);
+ is(MGA_Geoip::mga_geoip_continent_by_country($country), $cc[1], 'continent match for ' . $ip);
+}
diff --git a/lib/t/02_downloads_definitions.t b/lib/t/02_downloads_definitions.t
new file mode 100644
index 000000000..feb679092
--- /dev/null
+++ b/lib/t/02_downloads_definitions.t
@@ -0,0 +1,45 @@
+<?php
+
+require realpath(__DIR__ . '/../testmore.php');
+require realpath(__DIR__ . '/../../en/downloads/get/lib.php');
+require realpath(__DIR__ . '/../Downloads.php');
+
+plan('no_plan');
+
+diag('Testing functions');
+
+$mirrors = get_mirrors_for('dummy', 'de', 'DE');
+
+
+$testProd = array(
+ 'file' => 'file',
+ 'path' => 'path',
+ 'torrent' => 'torrent/path.torrent'
+);
+
+is('$MIRROR/path/file', get_download_link($testProd));
+
+
+diag('Testing downloads definitions.');
+
+
+$ini_file = realpath(__DIR__ . '/../../en/downloads/get/definitions.ini');
+$defs = parse_ini_file($ini_file, true);
+
+$keysRequired = array('path', 'file', 'name', 'size');
+$keysPreferred = array('sha1', 'md5');
+
+foreach ($defs as $prodKey => $values) {
+ diag(sprintf('Testing config for %s', $prodKey));
+ foreach ($keysRequired as $k)
+ ok($values[$k], 'has ' . $k);
+
+ foreach ($keysPreferred as $k) {
+ if (!array_key_exists($k, $values)) {
+ diag(sprintf('Beware, missing %s!', $k));
+ }
+ }
+
+ is(sprintf('$MIRROR/%s/%s', $values['path'], $values['file']), get_download_link($values), 'download link ok');
+}
+
diff --git a/lib/t/03_lang_redirection.t b/lib/t/03_lang_redirection.t
new file mode 100644
index 000000000..cb799c71b
--- /dev/null
+++ b/lib/t/03_lang_redirection.t
@@ -0,0 +1,13 @@
+<?php
+
+require realpath(__DIR__ . '/../testmore.php');
+require realpath(__DIR__ . '/../../langs.inc.php');
+
+plan('no_plan');
+
+diag('Testing langs.inc.php functions.');
+
+
+is(relocate($langs, null, 'en', 'en'), '/en/');
+is(relocate($langs, null, 'en', 'pt-BR,pt;q=0.8,es;q=0.6,en-US;q=0.4,en;q=0.2'), '/pt-br/');
+