]> granicus.if.org Git - php/commitdiff
new unit test
authorGreg Beaver <cellog@php.net>
Sat, 1 Nov 2003 03:32:15 +0000 (03:32 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 1 Nov 2003 03:32:15 +0000 (03:32 +0000)
pear/tests/pear_dependency_checkPackageUninstall.phpt [new file with mode: 0644]

diff --git a/pear/tests/pear_dependency_checkPackageUninstall.phpt b/pear/tests/pear_dependency_checkPackageUninstall.phpt
new file mode 100644 (file)
index 0000000..1c1434f
--- /dev/null
@@ -0,0 +1,175 @@
+--TEST--
+PEAR_Dependency::checkPackageUninstall() test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+    echo 'skip';
+}
+?>
+--FILE--
+<?php
+
+require_once "PEAR/Registry.php";
+require_once "PEAR/Dependency.php";
+
+// snarfed from pear_registry.phpt
+$reg = new PEAR_Registry;
+$reg->statedir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'checkPackagetmp';
+
+$files1 = array(
+    "pkg1-1.php" => array(
+        "role" => "php",
+        ),
+    "pkg1-2.php" => array(
+        "role" => "php",
+        "baseinstalldir" => "pkg1",
+        ),
+    );
+$files2 = array(
+    "pkg2-1.php" => array(
+        "role" => "php",
+        ),
+    "pkg2-2.php" => array(
+        "role" => "php",
+        "baseinstalldir" => "pkg2",
+        ),
+    );
+$files3 = array(
+    "pkg3-1.php" => array(
+        "role" => "php",
+        ),
+    "pkg3-2.php" => array(
+        "role" => "php",
+        "baseinstalldir" => "pkg3",
+        ),
+    );
+
+$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0", "filelist" => $files2));
+$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0", "filelist" => $files3));
+
+$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0", "filelist" => $files1,
+    'release_deps' => array(
+        array('type' => 'pkg', 'name' => 'pkg3', 'rel' => 'not')
+        )));
+
+$dep = new PEAR_Dependency($reg);
+$msg = '';
+$warn = '';
+$ret = $dep->checkPackageUninstall($msg, $warn, 'pkg1');
+echo 'uninstall ok? ';
+echo $ret ? "no\n" : "yes\n";
+echo $msg . "\n";
+echo $warn . "\n";
+
+cleanall();
+
+$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0", "filelist" => $files2));
+$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0", "filelist" => $files3));
+
+$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0", "filelist" => $files1,
+    'release_deps' => array(
+        array('type' => 'pkg', 'name' => 'pkg2', 'rel' => 'ne', 'version' => '6.0')
+        )));
+
+$dep = new PEAR_Dependency($reg);
+$msg = '';
+$warn = '';
+$ret = $dep->checkPackageUninstall($msg, $warn, 'pkg2');
+echo 'uninstall ok? ';
+echo $ret ? "no\n" : "yes\n";
+echo $msg . "\n";
+echo $warn . "\n";
+
+cleanall();
+
+$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0", "filelist" => $files2));
+$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0", "filelist" => $files3));
+
+$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0", "filelist" => $files1,
+    'release_deps' => array(
+        array('type' => 'pkg', 'name' => 'pkg2', 'rel' => 'has')
+        )));
+
+$dep = new PEAR_Dependency($reg);
+$msg = '';
+$warn = '';
+$ret = $dep->checkPackageUninstall($msg, $warn, 'pkg2');
+echo 'uninstall ok? ';
+echo $ret ? "no\n" : "yes\n";
+echo $msg . "\n";
+echo $warn . "\n";
+
+cleanall();
+
+$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0", "filelist" => $files2));
+$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0", "filelist" => $files3));
+
+$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0", "filelist" => $files1,
+    'release_deps' => array(
+        array('type' => 'pkg', 'name' => 'pkg2', 'rel' => 'has', 'optional' => 'no')
+        )));
+
+$dep = new PEAR_Dependency($reg);
+$msg = '';
+$warn = '';
+$ret = $dep->checkPackageUninstall($msg, $warn, 'pkg2');
+echo 'uninstall ok? ';
+echo $ret ? "no\n" : "yes\n";
+echo $msg . "\n";
+echo $warn . "\n";
+
+cleanall();
+
+$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0", "filelist" => $files2));
+$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0", "filelist" => $files3));
+
+$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0", "filelist" => $files1,
+    'release_deps' => array(
+        array('type' => 'pkg', 'name' => 'pkg2', 'rel' => 'has', 'optional' => 'yes')
+        )));
+
+$dep = new PEAR_Dependency($reg);
+$msg = '';
+$warn = '';
+$ret = $dep->checkPackageUninstall($msg, $warn, 'pkg2');
+echo 'uninstall ok? ';
+echo $ret ? "no\n" : "yes\n";
+echo $msg . "\n";
+echo $warn . "\n";
+
+cleanall();
+
+// ------------------------------------------------------------------------- //
+
+function cleanall()
+{
+    $dp = opendir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'checkPackagetmp');
+    while ($ent = readdir($dp)) {
+        if (substr($ent, -4) == ".reg") {
+            unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'checkPackagetmp' . DIRECTORY_SEPARATOR . $ent);
+        }
+    }
+}
+
+?>
+--GET--
+--POST--
+--EXPECT--
+uninstall ok? yes
+
+
+uninstall ok? yes
+
+
+uninstall ok? no
+Package 'pkg1' depends on 'pkg2'
+
+
+uninstall ok? no
+Package 'pkg1' depends on 'pkg2'
+
+
+uninstall ok? yes
+
+
+Warning: Package 'pkg1' optionally depends on 'pkg2'
\ No newline at end of file