From 5c60fe3a0ede0e167034872282e13db6c0263e68 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sun, 30 Nov 2003 22:31:00 +0000 Subject: [PATCH] beginning framework for PEAR_Common::downloadHttp test --- pear/tests/pear_common_downloadHttp.phpt | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 pear/tests/pear_common_downloadHttp.phpt 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-- -- 2.40.0