Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add some tests to increase code coverage

git-svn-id: http://svn.php.net/repository/pear/packages/XML_Util/trunk@260198 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit c33fedb3d16f4bf27f32cf7fd665242291e1c28d 1 parent f23321b
Chuck Burgess authored
View
22 tests/testBasic_getDocTypeDeclaration.phpt
@@ -11,8 +11,20 @@ echo '=====XML_Util::getDocTypeDeclaration() basic tests=====' . PHP_EOL . PHP_E
echo "TEST: using root only" . PHP_EOL;
echo XML_Util::getDocTypeDeclaration("rootTag") . PHP_EOL . PHP_EOL;
-echo "TEST: using root and URI" . PHP_EOL;
+echo "TEST: using root and a string URI" . PHP_EOL;
echo XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd") . PHP_EOL . PHP_EOL;
+
+$uri = array(
+ 'uri' => 'http://pear.php.net/dtd/package-1.0',
+ 'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
+);
+$dtdEntry = '<!ELEMENT additionalInfo (#PCDATA)>';
+
+echo "TEST: using root and an array URI" . PHP_EOL;
+echo XML_Util::getDocTypeDeclaration("rootTag", $uri) . PHP_EOL . PHP_EOL;
+
+echo "TEST: using root and an array URI and an internal DTD entry" . PHP_EOL;
+echo XML_Util::getDocTypeDeclaration("rootTag", $uri, $dtdEntry) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
=====XML_Util::getDocTypeDeclaration() basic tests=====
@@ -20,5 +32,11 @@ echo XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd") . PHP_EOL . PHP
TEST: using root only
<!DOCTYPE rootTag>
-TEST: using root and URI
+TEST: using root and a string URI
<!DOCTYPE rootTag SYSTEM "myDocType.dtd">
+
+TEST: using root and an array URI
+<!DOCTYPE rootTag PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0">
+
+TEST: using root and an array URI and an internal DTD entry
+<!DOCTYPE rootTag PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0" [\n<!ELEMENT additionalInfo (#PCDATA)>\n]>
View
6 tests/testBasic_replaceEntities.phpt
@@ -14,6 +14,9 @@ $utf8 = 'This data contains special chars like <, >, & and " as well as ä, ö,
echo "TEST: basic usage" . PHP_EOL;
echo XML_Util::replaceEntities($data) . PHP_EOL . PHP_EOL;
+echo "TEST: basic usage but with bogus \$replaceEntities arg" . PHP_EOL;
+echo XML_Util::replaceEntities($data, 'I_AM_BOGUS') . PHP_EOL . PHP_EOL;
+
echo "TEST: basic usage with ENTITIES_XML" . PHP_EOL;
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
@@ -47,6 +50,9 @@ echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL
TEST: basic usage
This string contains &lt; &amp; &gt;.
+TEST: basic usage but with bogus $replaceEntities arg
+This string contains < & >.
+
TEST: basic usage with ENTITIES_XML
This string contains &lt; &amp; &gt;.
View
6 tests/testBasic_reverseEntities.phpt
@@ -14,6 +14,9 @@ $utf8 = 'This data contains special chars like &lt;, &gt;, &amp; and &quot; as w
echo "TEST: basic usage" . PHP_EOL;
echo XML_Util::reverseEntities($data) . PHP_EOL . PHP_EOL;
+echo "TEST: basic usage but with bogus \$replaceEntities arg" . PHP_EOL;
+echo XML_Util::reverseEntities($data, 'I_AM_BOGUS') . PHP_EOL . PHP_EOL;
+
echo "TEST: basic usage with ENTITIES_XML" . PHP_EOL;
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
@@ -47,6 +50,9 @@ echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL
TEST: basic usage
This string contains < & >.
+TEST: basic usage but with bogus $replaceEntities arg
+This string contains &lt; &amp; &gt;.
+
TEST: basic usage with ENTITIES_XML
This string contains < & >.
Please sign in to comment.
Something went wrong with that request. Please try again.