From: Greg Beaver Date: Sun, 30 Nov 2003 22:31:00 +0000 (+0000) Subject: beginning framework for PEAR_Common::downloadHttp test X-Git-Tag: php-5.0.0b3RC1~474 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c60fe3a0ede0e167034872282e13db6c0263e68;p=php beginning framework for PEAR_Common::downloadHttp test --- diff --git a/pear/tests/pear_common_downloadHttp.phpt b/pear/tests/pear_common_downloadHttp.phpt new file mode 100644 index 0000000000..e1c9cacc0e --- /dev/null +++ b/pear/tests/pear_common_downloadHttp.phpt @@ -0,0 +1,70 @@ +--TEST-- +PEAR_Common::downloadHttp test +--SKIPIF-- + +--FILE-- + 'pear.php.net', + 'php_dir' => $temp_path . DIRECTORY_SEPARATOR . 'php', + 'ext_dir' => $temp_path . DIRECTORY_SEPARATOR . 'ext', + 'data_dir' => $temp_path . DIRECTORY_SEPARATOR . 'data', + 'doc_dir' => $temp_path . DIRECTORY_SEPARATOR . 'doc', + 'test_dir' => $temp_path . DIRECTORY_SEPARATOR . 'test', + 'bin_dir' => $temp_path . DIRECTORY_SEPARATOR . 'bin',)); +touch($temp_path . DIRECTORY_SEPARATOR . 'pear.conf'); +$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'pear.conf', 'w'); +fwrite($fp, $config); +fclose($fp); +touch($temp_path . DIRECTORY_SEPARATOR . 'pear.ini'); +$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'pear.ini', 'w'); +fwrite($fp, $config); +fclose($fp); + +putenv('PHP_PEAR_SYSCONF_DIR=' . $temp_path); +$home = getenv('HOME'); +if (!empty($home)) { + // for PEAR_Config initialization + putenv('HOME="'.$temp_path); +} + +require_once "PEAR/Common.php"; + +$common = &new PEAR_Common; + +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchit'); + +function catchit($err) +{ + echo "Caught error: " . $err->getMessage() . "\n"; +} + +cleanall($temp_path); + +// ------------------------------------------------------------------------- // + +function cleanall($dir) +{ + $dp = opendir($dir); + while ($ent = readdir($dp)) { + if ($ent == '.' || $ent == '..') { + continue; + } + if (is_dir($ent)) { + cleanall($dir . DIRECTORY_SEPARATOR . $ent); + } else { + unlink($dir . DIRECTORY_SEPARATOR . $ent); + } + } + closedir($dp); + rmdir($dir); +} +?> +--GET-- +--POST-- +--EXPECT--