]> granicus.if.org Git - php/commitdiff
start on a new unit test
authorGreg Beaver <cellog@php.net>
Sat, 29 Nov 2003 19:39:51 +0000 (19:39 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 29 Nov 2003 19:39:51 +0000 (19:39 +0000)
pear/tests/pear_common_infoFromString.phpt [new file with mode: 0644]

diff --git a/pear/tests/pear_common_infoFromString.phpt b/pear/tests/pear_common_infoFromString.phpt
new file mode 100644 (file)
index 0000000..0afc60a
--- /dev/null
@@ -0,0 +1,66 @@
+--TEST--
+PEAR_Common::analyzeSourceCode test
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+    echo 'skip';
+}
+if (!function_exists('token_get_all')) {
+    echo 'skip';
+}
+?>
+--FILE--
+<?php
+putenv('PHP_PEAR_SYSCONF_DIR=' . dirname(__FILE__));
+
+require_once "PEAR/Common.php";
+
+$common = &new PEAR_Common;
+
+PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchit');
+
+function catchit($err)
+{
+    echo "Caught error: " . $err->getMessage() . "\n";
+}
+
+echo "Test invalid XML\n";
+
+$common->infoFromString('\\goober');
+
+echo "Test valid XML, not a package.xml\n";
+
+$common->infoFromString('<?xml version="1.0" encoding="ISO-8859-1" ?>' .
+    "\n<grobbage></grobbage>");
+
+echo "Test valid package.xml, invalid version number\n";
+
+$common->infoFromString('<?xml version="1.0" encoding="ISO-8859-1" ?>' .
+    '<package version="10000000"></package>');
+
+echo "Test empty package.xml\n";
+
+$ret = $common->infoFromString('<?xml version="1.0" encoding="ISO-8859-1" ?>' .
+    '<package version="1.0"></package>');
+
+var_dump($ret);
+
+?>
+--GET--
+--POST--
+--EXPECT--
+Test invalid XML
+Caught error: XML error: not well-formed (invalid token) at line 1
+Test valid XML, not a package.xml
+Caught error: Invalid Package File, no <package> tag
+Test valid package.xml, invalid version number
+Caught error: No handlers for package.xml version 10000000
+Test empty package.xml
+array(2) {
+  ["provides"]=>
+  array(0) {
+  }
+  ["filelist"]=>
+  &array(0) {
+  }
+}
\ No newline at end of file