2
PEAR_Installer test #4: PEAR_Installer::install() with channels
5
if (!getenv('PHP_PEAR_RUNTESTS')) {
11
$temp_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp';
12
if (!is_dir($temp_path)) {
15
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'php')) {
16
mkdir($temp_path . DIRECTORY_SEPARATOR . 'php');
17
mkdir($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob');
19
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'data')) {
20
mkdir($temp_path . DIRECTORY_SEPARATOR . 'data');
22
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'doc')) {
23
mkdir($temp_path . DIRECTORY_SEPARATOR . 'doc');
25
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'test')) {
26
mkdir($temp_path . DIRECTORY_SEPARATOR . 'test');
28
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'ext')) {
29
mkdir($temp_path . DIRECTORY_SEPARATOR . 'ext');
31
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'script')) {
32
mkdir($temp_path . DIRECTORY_SEPARATOR . 'script');
34
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'tmp')) {
35
mkdir($temp_path . DIRECTORY_SEPARATOR . 'tmp');
37
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'bin')) {
38
mkdir($temp_path . DIRECTORY_SEPARATOR . 'bin');
40
// make the fake configuration - we'll use one of these and it should work
41
$config = serialize(array('master_server' => 'pear.php.net',
42
'default_channel' => 'pear',
43
'php_dir' => $temp_path . DIRECTORY_SEPARATOR . 'php',
44
'ext_dir' => $temp_path . DIRECTORY_SEPARATOR . 'ext',
45
'data_dir' => $temp_path . DIRECTORY_SEPARATOR . 'data',
46
'doc_dir' => $temp_path . DIRECTORY_SEPARATOR . 'doc',
47
'test_dir' => $temp_path . DIRECTORY_SEPARATOR . 'test',
48
'bin_dir' => $temp_path . DIRECTORY_SEPARATOR . 'bin',
49
'__channels' => array(
51
'php_dir' => $temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob',
53
touch($temp_path . DIRECTORY_SEPARATOR . 'pear.conf');
54
$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'pear.conf', 'w');
57
touch($temp_path . DIRECTORY_SEPARATOR . 'pear.ini');
58
$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'pear.ini', 'w');
62
putenv('PHP_PEAR_SYSCONF_DIR='.$temp_path);
63
$home = getenv('HOME');
65
// for PEAR_Config initialization
66
putenv('HOME="'.$temp_path);
68
require_once 'PEAR/ChannelFile.php';
69
require_once 'PEAR/Registry.php';
70
$reg = &new PEAR_Registry($temp_path . DIRECTORY_SEPARATOR . 'php');
71
$chan = new PEAR_ChannelFile;
72
$chan->setName('frob');
73
$chan->setSummary('test');
74
$chan->setServer('test');
75
$reg->addChannel($chan);
76
$chan->setName('groob');
77
$reg->addChannel($chan);
78
require_once "PEAR/Installer.php";
80
// no UI is needed for these tests
82
$installer = new PEAR_Installer($ui);
84
chdir(dirname(__FILE__));
86
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchit');
88
$error_to_catch = false;
89
function catchit($err)
91
global $error_to_catch;
92
if ($error_to_catch) {
93
if ($err->getMessage() == $error_to_catch) {
94
$error_to_catch = false;
95
echo "Caught expected error\n";
99
echo "Caught error: " . $err->getMessage() . "\n";
102
echo "Test package.xml direct install:\n";
103
$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'package2.xml');
104
$reg = &new PEAR_Registry($temp_path . DIRECTORY_SEPARATOR . 'php');
105
var_dump($reg->listAllPackages());
106
echo "zoorb.php exists? ";
107
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob'
108
. DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n";
109
echo "goompness/Mopreeb.php exists? ";
110
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob'
111
. DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness'
112
. DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n";
113
echo "goompness/oggbrzitzkee.php exists? ";
114
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob'
115
. DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness'
116
. DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n";
117
echo "goompness/test.dat exists? ";
118
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'pkg6'
119
. DIRECTORY_SEPARATOR . 'goompness'
120
. DIRECTORY_SEPARATOR . 'test.dat')) ? "yes\n" : "no\n";
122
echo "Test conflicting files:\n";
123
$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'conflictpackage2.xml');
125
echo "Test unknown channel:\n";
126
$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'package2_invalid.xml');
128
echo "After uninstall:\n";
129
$installer->uninstall('frob::pkg6');
130
var_dump($reg->listAllPackages());
131
echo "zoorb.php exists? ";
132
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob'
133
. DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n";
134
echo "goompness/Mopreeb.php exists? ";
135
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob'
136
. DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness'
137
. DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n";
138
echo "goompness/oggbrzitzkee.php exists? ";
139
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'frob'
140
. DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness'
141
. DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n";
142
echo "goompness/test.dat exists? ";
143
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'pkg6'
144
. DIRECTORY_SEPARATOR . 'goompness'
145
. DIRECTORY_SEPARATOR . 'test.dat')) ? "yes\n" : "no\n";
148
cleanall($temp_path);
150
// ------------------------------------------------------------------------- //
152
function cleanall($dir)
155
while ($ent = readdir($dp)) {
156
if ($ent == '.' || $ent == '..') {
159
if (is_dir($dir . DIRECTORY_SEPARATOR . $ent)) {
160
cleanall($dir . DIRECTORY_SEPARATOR . $ent);
162
unlink($dir . DIRECTORY_SEPARATOR . $ent);
172
Test package.xml direct install:
186
zoorb.php exists? yes
187
goompness/Mopreeb.php exists? yes
188
goompness/oggbrzitzkee.php exists? yes
189
goompness/test.dat exists? yes
190
Test conflicting files:
191
Caught error: groob::pkg6conflict: conflicting files found:
192
groob\goompness\oggbrzitzkee.php (frob::pkg6)
193
groob\goompness\Mopreeb.php (frob::pkg6)
194
groob\goompness\test.dat (frob::pkg6)
196
Test unknown channel:
197
Error: Unknown channel, "gorp"
198
Caught error: Installation failed: invalid package file, use option force to install anyway
212
goompness/Mopreeb.php exists? no
213
goompness/oggbrzitzkee.php exists? no
214
goompness/test.dat exists? no