From 036ac99eefed7fa923df2346bf27d3c06ede7d5f Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Mon, 1 Dec 2003 04:51:21 +0000 Subject: [PATCH] new test case and supporting files - incomplete, but works as it is --- pear/tests/pear_installer4.phpt | 259 ++++++++++++++++++ pear/tests/test-pkg6/goompness/Mopreeb.php | 11 + .../test-pkg6/goompness/oggbrzitzkee.php | 11 + pear/tests/test-pkg6/invalidtgz.tgz | 35 +++ pear/tests/test-pkg6/nopackagexml.tgz | Bin 0 -> 272 bytes pear/tests/test-pkg6/package.xml | 35 +++ pear/tests/test-pkg6/pkg6-1.1.tgz | Bin 0 -> 673 bytes pear/tests/test-pkg6/zoorb.php | 11 + 8 files changed, 362 insertions(+) create mode 100644 pear/tests/pear_installer4.phpt create mode 100644 pear/tests/test-pkg6/goompness/Mopreeb.php create mode 100644 pear/tests/test-pkg6/goompness/oggbrzitzkee.php create mode 100644 pear/tests/test-pkg6/invalidtgz.tgz create mode 100644 pear/tests/test-pkg6/nopackagexml.tgz create mode 100644 pear/tests/test-pkg6/package.xml create mode 100644 pear/tests/test-pkg6/pkg6-1.1.tgz create mode 100644 pear/tests/test-pkg6/zoorb.php diff --git a/pear/tests/pear_installer4.phpt b/pear/tests/pear_installer4.phpt new file mode 100644 index 0000000000..c9af6c43b0 --- /dev/null +++ b/pear/tests/pear_installer4.phpt @@ -0,0 +1,259 @@ +--TEST-- +PEAR_Installer test #4: PEAR_Installer::install() +--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/Installer.php"; + +// no UI is needed for these tests +$ui = false; +$installer = new PEAR_Installer($ui); +$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"; +} + +echo "Test package.xml direct install:\n"; +$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'package.xml'); +$reg = &new PEAR_Registry($temp_path . DIRECTORY_SEPARATOR . 'php'); +var_dump($reg->listPackages()); +echo "zoorb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n"; +echo "goompness/Mopreeb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n"; +echo "goompness/oggbrzitzkee.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n"; +echo "After uninstall:\n"; +$installer->uninstall('pkg6'); +var_dump($reg->listPackages()); +echo "zoorb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n"; +echo "goompness/Mopreeb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n"; +echo "goompness/oggbrzitzkee.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n"; +echo "goompness exists? "; +echo (is_dir($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness')) + ? "yes\n" : "no\n"; + +echo "Test .tgz install:\n"; +$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'pkg6-1.1.tgz'); +$reg = &new PEAR_Registry($temp_path . DIRECTORY_SEPARATOR . 'php'); +var_dump($reg->listPackages()); +echo "zoorb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n"; +echo "goompness/Mopreeb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n"; +echo "goompness/oggbrzitzkee.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n"; +echo "After uninstall:\n"; +$installer->uninstall('pkg6'); +var_dump($reg->listPackages()); +echo "zoorb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n"; +echo "goompness/Mopreeb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n"; +echo "goompness/oggbrzitzkee.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n"; +echo "goompness exists? "; +echo (is_dir($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness')) + ? "yes\n" : "no\n"; + +echo "Test invalid .tgz install:\n"; +$error_to_catch = 'unable to unpack ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . + 'test-pkg6' . DIRECTORY_SEPARATOR . 'invalidtgz.tgz'; +$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'invalidtgz.tgz'); +$reg = &new PEAR_Registry($temp_path . DIRECTORY_SEPARATOR . 'php'); +var_dump($reg->listPackages()); +echo "zoorb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n"; +echo "goompness/Mopreeb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n"; +echo "goompness/oggbrzitzkee.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n"; + +echo "Test missing package.xml in .tgz install:\n"; +$installer->install(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test-pkg6' . DIRECTORY_SEPARATOR . 'nopackagexml.tgz'); +$reg = &new PEAR_Registry($temp_path . DIRECTORY_SEPARATOR . 'php'); +var_dump($reg->listPackages()); +echo "zoorb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'zoorb.php')) ? "yes\n" : "no\n"; +echo "goompness/Mopreeb.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'Mopreeb.php')) ? "yes\n" : "no\n"; +echo "goompness/oggbrzitzkee.php exists? "; +echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'php' + . DIRECTORY_SEPARATOR . 'groob' . DIRECTORY_SEPARATOR . 'goompness' + . DIRECTORY_SEPARATOR . 'oggbrzitzkee.php')) ? "yes\n" : "no\n"; + +chdir($curdir); +cleanall($temp_path); + +// ------------------------------------------------------------------------- // + +function cleanall($dir) +{ + $dp = opendir($dir); + while ($ent = readdir($dp)) { + if ($ent == '.' || $ent == '..') { + continue; + } + if (is_dir($dir . DIRECTORY_SEPARATOR . $ent)) { + cleanall($dir . DIRECTORY_SEPARATOR . $ent); + } else { + unlink($dir . DIRECTORY_SEPARATOR . $ent); + } + } + closedir($dp); + rmdir($dir); +} +?> +--GET-- +--POST-- +--EXPECT-- +Test package.xml direct install: +array(1) { + [0]=> + string(4) "pkg6" +} +zoorb.php exists? yes +goompness/Mopreeb.php exists? yes +goompness/oggbrzitzkee.php exists? yes +After uninstall: +array(0) { +} +zoorb.php exists? no +goompness/Mopreeb.php exists? no +goompness/oggbrzitzkee.php exists? no +goompness exists? no +Test .tgz install: +array(1) { + [0]=> + string(4) "pkg6" +} +zoorb.php exists? yes +goompness/Mopreeb.php exists? yes +goompness/oggbrzitzkee.php exists? yes +After uninstall: +array(0) { +} +zoorb.php exists? no +goompness/Mopreeb.php exists? no +goompness/oggbrzitzkee.php exists? no +goompness exists? no +Test invalid .tgz install: +Caught error: Invalid checksum for file " + \ No newline at end of file diff --git a/pear/tests/test-pkg6/goompness/oggbrzitzkee.php b/pear/tests/test-pkg6/goompness/oggbrzitzkee.php new file mode 100644 index 0000000000..5422435ff8 --- /dev/null +++ b/pear/tests/test-pkg6/goompness/oggbrzitzkee.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/pear/tests/test-pkg6/invalidtgz.tgz b/pear/tests/test-pkg6/invalidtgz.tgz new file mode 100644 index 0000000000..909d507ca6 --- /dev/null +++ b/pear/tests/test-pkg6/invalidtgz.tgz @@ -0,0 +1,35 @@ + + + + pkg6 + required test for PEAR_Installer + + fake package + + PHP License + + + fakeuser + Joe Shmoe + nobody@example.com + lead + + + + 1.1 + 2003-09-09 + stable + + required dependency test + + + + zoorb.php + + oggbrzitzkee.php + Mopreeb.php + + + + + diff --git a/pear/tests/test-pkg6/nopackagexml.tgz b/pear/tests/test-pkg6/nopackagexml.tgz new file mode 100644 index 0000000000000000000000000000000000000000..8b9d9aad02eb476cb7d68aa4d5d803878c42053e GIT binary patch literal 272 zcmV+r0q_1FiwFpQ$jUze0B&z^VPk7yXJvS8Y%X+RaschtPiw;<7zXg11Njc`p{Kwa z%^$s#cGn*IA=*xCNE<~%VHx}GH66Q@vMnrQusy$n%8Mu>k7ye$9{8MRy)kY#w+9TI zH%d+NAdJd?RSktwl=S_>!KaY_|LsoxH^w@pCj1MG%D?2Hz>Bh?X*P!sA^!jX00000 W0000000000f5QburwP^oC;$L1e1OOR literal 0 HcmV?d00001 diff --git a/pear/tests/test-pkg6/package.xml b/pear/tests/test-pkg6/package.xml new file mode 100644 index 0000000000..102f972766 --- /dev/null +++ b/pear/tests/test-pkg6/package.xml @@ -0,0 +1,35 @@ + + + + pkg6 + required test for PEAR_Installer + + fake package + + PHP License + + + fakeuser + Joe Shmoe + nobody@example.com + lead + + + + 1.1 + 2003-09-09 + stable + + required dependency test + + + + zoorb.php + + oggbrzitzkee.php + Mopreeb.php + + + + + diff --git a/pear/tests/test-pkg6/pkg6-1.1.tgz b/pear/tests/test-pkg6/pkg6-1.1.tgz new file mode 100644 index 0000000000000000000000000000000000000000..09868cab447b01c072f13d50f86930f437e5978c GIT binary patch literal 673 zcmV;S0$%+eiwFP!000003+z{4Z`wc%=Q$GJ!HfEY1eZ`q+UW?Lwo2=?s%Y&?rAbpr z+z^rEvP-B+r+xSNE`&lisq0GDhvp{;KHKN>pRbQVrpm)L$|4ro$h3Qw377>UjI(HDo}8a`4-STh zUE74QXYe;4&fZ^KPL3h3t__@Do?jfFf;lV8{4HZS`m&eL@?M4|3(JtL^t#F}?XS0O zo#(X;0G|0NdigwZIMbwN7K=3X<9 z`&x)(Eb%fi72)y-Z~Qb*uosAwvr1CyNs*wJpdWIk$;uP9?aJo5&NCeS@rCm z%~`#uM4?}z*SDQYfQw7k;2iW5xYqFhI<7@*=EnRIDPm{KfpRnst*BQughOifT39htX6 z$f>$qCi^!7kq~K~VNrY)Q8bmead|sO+>OOkkxRra_c+^(m+D&Aiq~D?886-at(NLI z>Q0-j)4TgK9+>}N_ucjU@9(Sm?^^UVuzN=u{02UzlDCbv!8#q9e;rT{O&qNz2<)AN zdle@T`BKKwtOPYmv}%X7jUe%hLifA<hZ( zfir-o2iM?1H2wd&@rVB3_${-WGal9du1ySkzxn_7f6(-Qg9fh`zW@LL|NjF3_w;4> H02BZKhCNr( literal 0 HcmV?d00001 diff --git a/pear/tests/test-pkg6/zoorb.php b/pear/tests/test-pkg6/zoorb.php new file mode 100644 index 0000000000..5422435ff8 --- /dev/null +++ b/pear/tests/test-pkg6/zoorb.php @@ -0,0 +1,11 @@ + \ No newline at end of file -- 2.50.1