summaryrefslogtreecommitdiff
path: root/pear/tests/pear_installer1.phpt
blob: 90c710cba754503a573178046b0b81e164fa9273 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
--TEST--
PEAR_Installer test #1
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
    echo 'skip';
}
?>
--FILE--
<?php

require_once "PEAR/Installer.php";

$temp_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp';
if (!is_dir($temp_path)) {
    mkdir($temp_path);
}
touch($temp_path . DIRECTORY_SEPARATOR . 'user.conf');
// no UI is needed for these tests
$ui = false;
$installer = new PEAR_Installer($ui);
echo "test extractDownloadFileName:\n";
echo 'existing file: ';
echo ($temp_path . DIRECTORY_SEPARATOR . 'user.conf' ==
     $installer->extractDownloadFileName($temp_path . DIRECTORY_SEPARATOR . 'user.conf',
    $ui)) ? "yes\n" : "no\n";
var_dump($ui);
echo 'invalid match: ';
echo $installer->extractDownloadFileName('27',
    $ui);
echo "\n";
var_dump($ui);
echo 'valid match, no version: ';
echo $installer->extractDownloadFileName('Testpackage', $ui);
echo "\n";
var_dump($ui);
echo 'invalid match, has invalid version: ';
echo $installer->extractDownloadFileName('Testpackage-##', $ui);
echo "\n";
var_dump($ui);
echo 'valid match, has version: ';
echo $installer->extractDownloadFileName('Testpackage-1.2', $ui);
echo "\n";
var_dump($ui);

echo "\ntest checkDeps 1:\n";
$fakerel = array('release_deps' =>
array(
    array(
        'type' => 'pkg',
        'rel '=> 'has',
        'name' => 'foo',
        'optional' => 'yes'
    ),
    array(
        'type' => 'pkg',
        'rel '=> 'ge',
        'version' => '1.6',
        'name' => 'bar',
    ),
));
$res = '';
var_dump($installer->checkDeps($fakerel, $res));
var_dump($res);
$fakerel = array('release_deps' =>
array(
    array(
        'type' => 'pkg',
        'rel '=> 'has',
        'name' => 'foo',
        'optional' => 'yes'
    ),
));
echo "\ntest checkDeps 2:\n";
$res = '';
var_dump($installer->checkDeps($fakerel, $res));
var_dump($res);
unlink($temp_path . DIRECTORY_SEPARATOR . 'user.conf');
rmdir($temp_path);
?>
--GET--
--POST--
--EXPECT--
test extractDownloadFileName:
existing file: yes
bool(false)
invalid match: 27
NULL
valid match, no version: Testpackage
NULL
invalid match, has invalid version: Testpackage-##
NULL
valid match, has version: Testpackage
string(3) "1.2"

test checkDeps 1:
bool(true)
string(23) "
requires package `bar'"

test checkDeps 2:
bool(false)
string(77) "Optional dependencies:
package `foo' is recommended to utilize some features."