diff options
Diffstat (limited to 'lib/t/02_downloads_definitions.t')
-rw-r--r-- | lib/t/02_downloads_definitions.t | 45 |
1 files changed, 45 insertions, 0 deletions
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'); +} + |