summaryrefslogtreecommitdiff
path: root/pear
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2004-06-01 14:27:54 +0000
committerGreg Beaver <cellog@php.net>2004-06-01 14:27:54 +0000
commitcb0b01f7c2f3fe848dba65f3ff81059631d849d4 (patch)
tree419020601750eaded7a696cd5c3c5355db182ccb /pear
parenta0ebaab05240feb00ac783471a4003232e5faaf6 (diff)
downloadphp-git-cb0b01f7c2f3fe848dba65f3ff81059631d849d4.tar.gz
file needed for registry test
Diffstat (limited to 'pear')
-rw-r--r--pear/tests/pear_registry_inc.php.inc74
1 files changed, 74 insertions, 0 deletions
diff --git a/pear/tests/pear_registry_inc.php.inc b/pear/tests/pear_registry_inc.php.inc
new file mode 100644
index 0000000000..7cc395f081
--- /dev/null
+++ b/pear/tests/pear_registry_inc.php.inc
@@ -0,0 +1,74 @@
+<?php
+
+// ------------------------------------------------------------------------- //
+
+function cleanall($dir = null)
+{
+ if ($dir !== null) {
+ $statedir = $dir;
+ } else {
+ $statedir = $GLOBALS['statedir'];
+ }
+ if (file_exists($statedir)) {
+ $dp = opendir($statedir);
+ while ($ent = readdir($dp)) {
+ if (in_array($ent, array('.', '..'))) {
+ continue;
+ }
+ if (is_dir($statedir . DIRECTORY_SEPARATOR . $ent)) {
+ cleanall($statedir . DIRECTORY_SEPARATOR . $ent);
+ continue;
+ }
+ unlink($statedir . DIRECTORY_SEPARATOR . $ent);
+ }
+ closedir($dp);
+ rmdir($statedir);
+ }
+}
+
+
+function dumpall(&$reg)
+{
+ print "dumping registry...\n";
+ $infos = $reg->allPackageInfo();
+ foreach ($infos as $channel => $info) {
+ echo "channel $channel:\n";
+ foreach ($info as $pkg) {
+ print $pkg["name"] . ":";
+ unset($pkg["name"]);
+ foreach ($pkg as $k => $v) {
+ if ($k == '_lastmodified') continue;
+ if (is_array($v) && $k == 'filelist') {
+ print " $k=array(";
+ $i = 0;
+ foreach ($v as $k2 => $v2) {
+ if ($i++ > 0) print ",";
+ print "{$k2}[";
+ $j = 0;
+ foreach ($v2 as $k3 => $v3) {
+ if ($j++ > 0) print ",";
+ print "$k3=$v3";
+ }
+ print "]";
+ }
+ print ")";
+ } else {
+ print " $k=\"$v\"";
+ }
+ }
+ print "\n";
+ }
+ }
+ print "dump done\n";
+}
+
+require_once 'PEAR/ErrorStack.php';
+function dump_error($err)
+{
+ echo "caught ErrorStack error:\n";
+ echo "message: ". $err['message'] . "\n";
+ echo "code: ". $err['code'] . "\n";
+}
+PEAR_ErrorStack::setDefaultCallback('dump_error');
+register_shutdown_function('cleanall');
+?> \ No newline at end of file