From 541ebbeaebd2e9149c98f6e7a3cfb6933205c316 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Thu, 11 Dec 2003 15:56:08 +0000 Subject: [PATCH] new unit test for PEAR_Packager --- pear/tests/dirtree/pkg1-1.0.tgz | Bin 0 -> 560 bytes pear/tests/dirtree/pkg2-1.0.tgz | Bin 0 -> 608 bytes pear/tests/pear_packager.phpt | 423 ++++++++++++++++++++++++++++++++ 3 files changed, 423 insertions(+) create mode 100644 pear/tests/dirtree/pkg1-1.0.tgz create mode 100644 pear/tests/dirtree/pkg2-1.0.tgz create mode 100644 pear/tests/pear_packager.phpt diff --git a/pear/tests/dirtree/pkg1-1.0.tgz b/pear/tests/dirtree/pkg1-1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..ab305f74a885c22cd0556e2676bba8ed8890a084 GIT binary patch literal 560 zcmV-00?+*)iwFP!000003+z?jZ`v>r?laQ<2hZ=|I5bH&8F$l$v{svnMqesbnhY^u z;l!C^ruM(zImQflnYI<}g-=SjUp}9|JBLQh*J3FLPnEtn6=;&=d5$iSM{@Lw5WUPP zLPe41G$}Hgf+q#s*CvruXA72(O%L-V)MCVF%5s8Pw8|(v@Tz*Y|m0eOz|1AAi+D zh}EK!yjd?PBc0e8+f7vo`^>HUzEM_|$jR2Bg|TQde*g8`P2D=7wX}@H$ZlCF+qqSZ zgDv<%tYs{hk$q1WS_xG5%@0kW)(1NEn&=S5-7W%SdIT%C0 zLTRa0>vl)=2ILPp!Z0Zq&ENnkG_q87gnf%K@+^*Uwb4!iW!uc{qaP5Tzz-QFf0fgx zc(kG}O?8}!k^O3+6_H*R2buT&_l137csBg)B*#>feX9R$kKcU%JH>zhv!ck-4E_sf yS`5K|#_6%^zZb~iwRovL{-FQGFw3F;A^war&NwZ80ssL2{{sLPXhfj^3;+NLFb}l= literal 0 HcmV?d00001 diff --git a/pear/tests/dirtree/pkg2-1.0.tgz b/pear/tests/dirtree/pkg2-1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..18bc9d2f48ce582505f0328572c5207eae22948f GIT binary patch literal 608 zcmV-m0-yaKiwFP!000003+z^3kJ>N{zh|UHvK)G>=X(UoM5bA}7t7=hL0Spp?G8Gjj*ua@W339SjjjOO^B<*2hOt0^UxMAVSTGTp;$ zrPgAe<&bB!-ksG5h&koZ!&dRg3{Q~RN~W0_dZxx6F)$9jVx8*@G242sr=~-U1Jh+5 z{VSg(@{lSi_0+sx&l?n#-k`zM%J$r82u=?{!IHZ&a(7`w=Re(lgQvNj^b~1&i1fe3 zcwzoG3p4)*5srT}BrJ&fsBh`=w5$KVkLls9c#Rn6)IaRw|37093&?APZs`U3Q~li> uqq{jqkLTE#G0v%f#LWE +--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 -- 2.50.1