Permalink
Browse files

add some tests to increase code coverage

git-svn-id: http://svn.php.net/repository/pear/packages/XML_Util/trunk@260199 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent c33fedb commit fd495426797c423138d01a2f8a4a6e3976a728e3 @ashnazg ashnazg committed May 24, 2008
Showing with 27 additions and 0 deletions.
  1. +27 −0 tests/testBasic_attributesToString.phpt
@@ -9,6 +9,19 @@ require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
echo '=====XML_Util::attributesToString() basic tests=====' . PHP_EOL . PHP_EOL;
$att = array("foo" => "bar", "boo" => "baz");
+$sort1 = array(
+ 'multiline' => true,
+ 'indent' => '----',
+ 'linebreak' => "^",
+ 'entities' => XML_UTIL_ENTITIES_XML,
+ 'sort' => true
+);
+$sort2 = array(
+ 'multiline' => true,
+ 'indent' => '----',
+ 'linebreak' => "^",
+ 'entities' => XML_UTIL_ENTITIES_XML,
+);
echo "TEST: basic usage" . PHP_EOL;
echo XML_Util::attributesToString($att) . PHP_EOL . PHP_EOL;
@@ -31,6 +44,12 @@ echo XML_Util::attributesToString($att, true, true, ' ') . PHP_EOL . PHP_
echo "TEST: explicit \$linebreak = '^' (some dummy char)" . PHP_EOL;
echo XML_Util::attributesToString($att, true, true, '^') . PHP_EOL . PHP_EOL;
+echo "TEST: passing \$sort array of options that includes 'sort'" . PHP_EOL;
+echo XML_Util::attributesToString($att, $sort1) . PHP_EOL . PHP_EOL;
+
+echo "TEST: passing \$sort array of options that doesn't include 'sort'" . PHP_EOL;
+echo XML_Util::attributesToString($att, $sort2) . PHP_EOL . PHP_EOL;
+
echo "TEST: do not replace entities" . PHP_EOL;
$arr = array("foo" => "b@&r", "boo" => "b><z");
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
@@ -78,6 +97,14 @@ TEST: explicit $linebreak = '^' (some dummy char)
boo="baz"
^foo="bar"
+TEST: passing $sort array of options that includes 'sort'
+ boo="baz"
+----foo="bar"
+
+TEST: passing $sort array of options that doesn't include 'sort'
+ boo="baz"
+----foo="bar"
+
TEST: do not replace entities
boo="b><z" foo="b@&r"

0 comments on commit fd49542

Please sign in to comment.