| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
PEAR_Info check if packages installed
|
|
|
3 |
--FILE--
|
|
|
4 |
<?php
|
|
|
5 |
$ds = DIRECTORY_SEPARATOR;
|
|
|
6 |
$dir = dirname(__FILE__);
|
|
|
7 |
$sysconfdir = $dir . $ds . 'sysconf_dir';
|
|
|
8 |
$peardir = $dir . $ds . 'pear_dir';
|
|
|
9 |
|
|
|
10 |
putenv("PHP_PEAR_SYSCONF_DIR=" . $sysconfdir);
|
|
|
11 |
chdir($dir);
|
|
|
12 |
|
|
|
13 |
// we get PEAR_Info class only here due to setting of PEAR_CONFIG_SYSCONFDIR
|
|
|
14 |
include_once 'PEAR/Info.php';
|
|
|
15 |
|
|
|
16 |
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
|
|
17 |
$conf_file = $sysconfdir . $ds . 'pearsys.ini';
|
|
|
18 |
} else {
|
|
|
19 |
$conf_file = $sysconfdir . $ds . 'pear.conf';
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
if (!file_exists($conf_file)) {
|
|
|
23 |
// write once PEAR system-wide config file for simulation
|
|
|
24 |
$config =& PEAR_Config::singleton();
|
|
|
25 |
$config->set('php_dir', $peardir);
|
|
|
26 |
$config->writeConfigFile($conf_file);
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* TestCase 1:
|
|
|
31 |
* check if a package named is installed, under pear.php.net channel.
|
|
|
32 |
*
|
|
|
33 |
* Must use the pear config files into the default system directory
|
|
|
34 |
* (PEAR_CONFIG_SYSCONFDIR).
|
|
|
35 |
*/
|
|
|
36 |
$testCase = 'testPackageNameInstall';
|
|
|
37 |
|
|
|
38 |
$GLOBALS['_PEAR_Config_instance'] = null;
|
|
|
39 |
|
|
|
40 |
$available = PEAR_Info::packageInstalled('Console_Getopt');
|
|
|
41 |
|
|
|
42 |
$result = ($available)
|
|
|
43 |
? 'OK' : 'Package Console_Getopt is not yet installed';
|
|
|
44 |
|
|
|
45 |
echo $testCase . ' : ' . $result;
|
|
|
46 |
echo "\n";
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* TestCase 2:
|
|
|
50 |
* check if a package is installed with a minimal version,
|
|
|
51 |
* under pear.php.net channel.
|
|
|
52 |
*
|
|
|
53 |
* Must use the pear config files into the default system directory
|
|
|
54 |
* (PEAR_CONFIG_SYSCONFDIR).
|
|
|
55 |
*/
|
|
|
56 |
$testCase = 'testPackageNameVersionInstall';
|
|
|
57 |
|
|
|
58 |
$GLOBALS['_PEAR_Config_instance'] = null;
|
|
|
59 |
|
|
|
60 |
$available = PEAR_Info::packageInstalled('Console_Getopt', '1.2.2');
|
|
|
61 |
|
|
|
62 |
$result = ($available)
|
|
|
63 |
? 'OK' : 'Package Console_Getopt is not installed,' .
|
|
|
64 |
' or version is less than 1.2.2';
|
|
|
65 |
|
|
|
66 |
echo $testCase . ' : ' . $result;
|
|
|
67 |
echo "\n";
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* TestCase 3:
|
|
|
71 |
* check if a channel/package named is installed.
|
|
|
72 |
*
|
|
|
73 |
* Must use the pear config files into the default system directory
|
|
|
74 |
* (PEAR_CONFIG_SYSCONFDIR).
|
|
|
75 |
*/
|
|
|
76 |
$testCase = 'testPackageNameChannelInstall';
|
|
|
77 |
|
|
|
78 |
$GLOBALS['_PEAR_Config_instance'] = null;
|
|
|
79 |
|
|
|
80 |
$available = PEAR_Info::packageInstalled('PHPUnit', null, 'pear.phpunit.de');
|
|
|
81 |
|
|
|
82 |
$result = ($available)
|
|
|
83 |
? 'OK' : 'Package PHPUnit is not yet installed';
|
|
|
84 |
|
|
|
85 |
echo $testCase . ' : ' . $result;
|
|
|
86 |
echo "\n";
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
* TestCase 4:
|
|
|
90 |
* check if a channel/package with a minimal version, is installed.
|
|
|
91 |
*
|
|
|
92 |
* Must use the pear config files into the default system directory
|
|
|
93 |
* (PEAR_CONFIG_SYSCONFDIR).
|
|
|
94 |
*/
|
|
|
95 |
$testCase = 'testPackageNameVersionChannelInstall';
|
|
|
96 |
|
|
|
97 |
$GLOBALS['_PEAR_Config_instance'] = null;
|
|
|
98 |
|
|
|
99 |
$available = PEAR_Info::packageInstalled('PHPUnit', '3.0.0', 'phpunit');
|
|
|
100 |
|
|
|
101 |
$result = ($available)
|
|
|
102 |
? 'OK' : 'Package phpunit/PHPUnit is not installed,' .
|
|
|
103 |
' or version is less than 3.0.0';
|
|
|
104 |
|
|
|
105 |
echo $testCase . ' : ' . $result;
|
|
|
106 |
?>
|
|
|
107 |
--CLEAN--
|
|
|
108 |
<?php
|
|
|
109 |
$ds = DIRECTORY_SEPARATOR;
|
|
|
110 |
$dir = dirname(__FILE__);
|
|
|
111 |
$sysconfdir = $dir . $ds . 'sysconf_dir';
|
|
|
112 |
|
|
|
113 |
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
|
|
114 |
$conf_file = $sysconfdir . $ds . 'pearsys.ini';
|
|
|
115 |
} else {
|
|
|
116 |
$conf_file = $sysconfdir . $ds . 'pear.conf';
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
unlink ($conf_file);
|
|
|
120 |
?>
|
|
|
121 |
--EXPECT--
|
|
|
122 |
testPackageNameInstall : OK
|
|
|
123 |
testPackageNameVersionInstall : OK
|
|
|
124 |
testPackageNameChannelInstall : OK
|
|
|
125 |
testPackageNameVersionChannelInstall : OK
|