aboutsummaryrefslogtreecommitdiffstats
path: root/lib/t/02_downloads_definitions.t
blob: feb6790925f16798877b8658d141011b12d36b2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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');
}