diff options
author | Romain d'Alverny <rda@mageia.org> | 2012-05-11 10:10:21 +0000 |
---|---|---|
committer | Romain d'Alverny <rda@mageia.org> | 2012-05-11 10:10:21 +0000 |
commit | 7e146d871dd476e59301f51036e4f9b53b7fbfdf (patch) | |
tree | a679a8e0c4cee5425f9255587aa8f6f0d4caf90d /lib | |
parent | 196a756c664b31143fb7cef24459c325a68cd332 (diff) | |
download | www-7e146d871dd476e59301f51036e4f9b53b7fbfdf.tar www-7e146d871dd476e59301f51036e4f9b53b7fbfdf.tar.gz www-7e146d871dd476e59301f51036e4f9b53b7fbfdf.tar.bz2 www-7e146d871dd476e59301f51036e4f9b53b7fbfdf.tar.xz www-7e146d871dd476e59301f51036e4f9b53b7fbfdf.zip |
new & updated tests for downloads section
Diffstat (limited to 'lib')
-rw-r--r-- | lib/t/01_mga_geoip.t | 15 | ||||
-rw-r--r-- | lib/t/02_downloads_definitions.t | 45 |
2 files changed, 53 insertions, 7 deletions
diff --git a/lib/t/01_mga_geoip.t b/lib/t/01_mga_geoip.t index a33a708a7..aa3daa674 100644 --- a/lib/t/01_mga_geoip.t +++ b/lib/t/01_mga_geoip.t @@ -8,6 +8,9 @@ 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'), @@ -15,14 +18,12 @@ $ips = array( => array('IE', 'EU'), '173.194.67.99' - => array('US', 'NA'), - - '46.33.75.17' - => array('DE', 'EU') + => array('US', 'NA') ); 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); -} + $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'); +} + |