From: Greg Beaver Date: Thu, 11 Dec 2003 15:56:08 +0000 (+0000) Subject: new unit test for PEAR_Packager X-Git-Tag: php-5.0.0b3RC1~129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=541ebbeaebd2e9149c98f6e7a3cfb6933205c316;p=php new unit test for PEAR_Packager --- diff --git a/pear/tests/dirtree/pkg1-1.0.tgz b/pear/tests/dirtree/pkg1-1.0.tgz new file mode 100644 index 0000000000..ab305f74a8 Binary files /dev/null and b/pear/tests/dirtree/pkg1-1.0.tgz differ diff --git a/pear/tests/dirtree/pkg2-1.0.tgz b/pear/tests/dirtree/pkg2-1.0.tgz new file mode 100644 index 0000000000..18bc9d2f48 Binary files /dev/null and b/pear/tests/dirtree/pkg2-1.0.tgz differ diff --git a/pear/tests/pear_packager.phpt b/pear/tests/pear_packager.phpt new file mode 100644 index 0000000000..d602478f9e --- /dev/null +++ b/pear/tests/pear_packager.phpt @@ -0,0 +1,423 @@ +--TEST-- +PEAR_Packager 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/Packager.php"; + +$packager = new PEAR_Packager(); +$curdir = getcwd(); +chdir(dirname(__FILE__)); + +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchit'); + +$error_to_catch = false; +function catchit($err) +{ + global $error_to_catch; + if ($error_to_catch) { + if ($err->getMessage() == $error_to_catch) { + $error_to_catch = false; + echo "Caught expected error\n"; + return; + } + } + echo "Caught error: " . $err->getMessage() . "\n"; +} +ob_start(); +$packager->package(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'dirtree' . DIRECTORY_SEPARATOR . 'package.xml'); +$packager->package(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'dirtree' . DIRECTORY_SEPARATOR . 'package2.xml'); +$stuff = str_replace(array(dirname(__FILE__) . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), array('', '/'), + ob_get_contents()); +ob_end_clean(); +echo $stuff; + +$archive1 = &new Archive_Tar(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pkg1-1.0.tgz'); +$archive1c = &new Archive_Tar(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'dirtree' . + DIRECTORY_SEPARATOR . 'pkg1-1.0.tgz'); +$x1 = $archive1->listContent(); +$x2 = $archive1c->listContent(); +for($i=0;$ilistContent(); +$x2 = $archive1c->listContent(); +for($i=0;$i +--GET-- +--POST-- +--EXPECT-- +Analyzing multiplepackages/pkg1file.php +Analyzing pkg1/randomfile.php +Package pkg1-1.0.tgz done +Tag the released code with `pear cvstag package.xml' +(or set the CVS tag RELEASE_1_0 by hand) +Analyzing multiplepackages/pkg2file.php +Analyzing nestedroot/rootfile.php +Analyzing nestedroot/emptydir/nesteddir/nestedfile.php +Package pkg2-1.0.tgz done +Tag the released code with `pear cvstag package2.xml' +(or set the CVS tag RELEASE_1_0 by hand) +array(3) { + [0]=> + array(6) { + ["filename"]=> + string(11) "package.xml" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(817) + ["typeflag"]=> + string(0) "" + } + [1]=> + array(8) { + ["checksum"]=> + int(5592) + ["filename"]=> + string(38) "pkg1-1.0/multiplepackages/pkg1file.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119017) + ["typeflag"]=> + string(0) "" + } + [2]=> + array(8) { + ["checksum"]=> + int(4534) + ["filename"]=> + string(28) "pkg1-1.0/pkg1/randomfile.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071120110) + ["typeflag"]=> + string(0) "" + } +} +array(3) { + [0]=> + array(6) { + ["filename"]=> + string(11) "package.xml" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(817) + ["typeflag"]=> + string(0) "" + } + [1]=> + array(8) { + ["checksum"]=> + int(5592) + ["filename"]=> + string(38) "pkg1-1.0/multiplepackages/pkg1file.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119017) + ["typeflag"]=> + string(0) "" + } + [2]=> + array(8) { + ["checksum"]=> + int(4534) + ["filename"]=> + string(28) "pkg1-1.0/pkg1/randomfile.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071120110) + ["typeflag"]=> + string(0) "" + } +} +array(4) { + [0]=> + array(6) { + ["filename"]=> + string(11) "package.xml" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(921) + ["typeflag"]=> + string(0) "" + } + [1]=> + array(8) { + ["checksum"]=> + int(5600) + ["filename"]=> + string(38) "pkg2-1.0/multiplepackages/pkg2file.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119030) + ["typeflag"]=> + string(0) "" + } + [2]=> + array(8) { + ["checksum"]=> + int(5066) + ["filename"]=> + string(32) "pkg2-1.0/nestedroot/rootfile.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119266) + ["typeflag"]=> + string(0) "" + } + [3]=> + array(8) { + ["checksum"]=> + int(7193) + ["filename"]=> + string(53) "pkg2-1.0/nestedroot/emptydir/nesteddir/nestedfile.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119310) + ["typeflag"]=> + string(0) "" + } +} +array(4) { + [0]=> + array(6) { + ["filename"]=> + string(11) "package.xml" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(921) + ["typeflag"]=> + string(0) "" + } + [1]=> + array(8) { + ["checksum"]=> + int(5600) + ["filename"]=> + string(38) "pkg2-1.0/multiplepackages/pkg2file.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119030) + ["typeflag"]=> + string(0) "" + } + [2]=> + array(8) { + ["checksum"]=> + int(5066) + ["filename"]=> + string(32) "pkg2-1.0/nestedroot/rootfile.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119266) + ["typeflag"]=> + string(0) "" + } + [3]=> + array(8) { + ["checksum"]=> + int(7193) + ["filename"]=> + string(53) "pkg2-1.0/nestedroot/emptydir/nesteddir/nestedfile.php" + ["mode"]=> + int(33206) + ["uid"]=> + int(0) + ["gid"]=> + int(0) + ["size"]=> + int(0) + ["mtime"]=> + int(1071119310) + ["typeflag"]=> + string(0) "" + } +} \ No newline at end of file