Initial Commit
This commit is contained in:
18
database/php/tests/XML_Util/tests/testBasic_apiVersion.phpt
Normal file
18
database/php/tests/XML_Util/tests/testBasic_apiVersion.phpt
Normal file
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
XML_Util::apiVersion() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::apiVersion() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic apiVersion() call" . PHP_EOL;
|
||||
echo XML_Util::apiVersion() . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::apiVersion() basic tests=====
|
||||
|
||||
TEST: basic apiVersion() call
|
||||
1.1
|
||||
@@ -0,0 +1,118 @@
|
||||
--TEST--
|
||||
XML_Util::attributesToString() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
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;
|
||||
|
||||
echo "TEST: explicit \$sort = true" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$sort = false" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$multiline = false" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$multiline = true" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: explicit \$indent = ' ' (8 spaces)" . PHP_EOL;
|
||||
echo XML_Util::attributesToString($att, true, true, ' ') . PHP_EOL . PHP_EOL;
|
||||
|
||||
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,
|
||||
XML_UTIL_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: replace all XML entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: replace only required XML entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: replace HTML entities" . PHP_EOL;
|
||||
$arr = array("foo" => "b@&r", "boo" => "b><z");
|
||||
echo XML_Util::attributesToString($arr, true, false, ' ', PHP_EOL,
|
||||
XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::attributesToString() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
boo="baz" foo="bar"
|
||||
|
||||
TEST: explicit $sort = true
|
||||
boo="baz" foo="bar"
|
||||
|
||||
TEST: explicit $sort = false
|
||||
foo="bar" boo="baz"
|
||||
|
||||
TEST: explicit $multiline = false
|
||||
boo="baz" foo="bar"
|
||||
|
||||
TEST: explicit $multiline = true
|
||||
boo="baz"
|
||||
foo="bar"
|
||||
|
||||
TEST: explicit $indent = ' ' (8 spaces)
|
||||
boo="baz"
|
||||
foo="bar"
|
||||
|
||||
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"
|
||||
|
||||
TEST: replace all XML entities
|
||||
boo="b><z" foo="b@&r"
|
||||
|
||||
TEST: replace only required XML entities
|
||||
boo="b><z" foo="b@&r"
|
||||
|
||||
TEST: replace HTML entities
|
||||
boo="b><z" foo="b@&r"
|
||||
@@ -0,0 +1,52 @@
|
||||
--TEST--
|
||||
XML_Util::collapseEmptyTags() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::collapseEmptyTags() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$emptyTag = "<foo></foo>";
|
||||
$otherTag = "<bar>baz</bar>";
|
||||
$xhtmlTag = "<b></b>";
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage alongside non-empty tag" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag . $otherTag) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag, with COLLAPSE_ALL set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag alongside non-empty tag, with COLLAPSE_ALL set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_ALL) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag, with COLLAPSE_XHTML_ONLY set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: one empty tag alongside non-empty tag, with COLLAPSE_XHTML_ONLY set" . PHP_EOL;
|
||||
echo XML_Util::collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL_COLLAPSE_XHTML_ONLY) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::collapseEmptyTags() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
<foo />
|
||||
|
||||
TEST: basic usage alongside non-empty tag
|
||||
<foo /><bar>baz</bar>
|
||||
|
||||
TEST: one empty tag, with COLLAPSE_ALL set
|
||||
<foo />
|
||||
|
||||
TEST: one empty tag alongside non-empty tag, with COLLAPSE_ALL set
|
||||
<foo /><bar>baz</bar>
|
||||
|
||||
TEST: one empty tag, with COLLAPSE_XHTML_ONLY set
|
||||
<foo></foo>
|
||||
|
||||
TEST: one empty tag alongside non-empty tag, with COLLAPSE_XHTML_ONLY set
|
||||
<foo></foo><b></b><bar>baz</bar>
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
XML_Util::createCDataSection() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createCDataSection() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::createCDataSection("I am content.") . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createCDataSection() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
<![CDATA[I am content.]]>
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
XML_Util::createComment() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createComment() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage" . PHP_EOL;
|
||||
echo XML_Util::createComment("I am comment.") . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createComment() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
<!-- I am comment. -->
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
XML_Util::createEndElement() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createEndElement() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage (myTag)" . PHP_EOL;
|
||||
echo XML_Util::createEndElement("myTag") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a namespaced tag (myNs:myTag)" . PHP_EOL;
|
||||
echo XML_Util::createEndElement("myNs:myTag") . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createEndElement() basic tests=====
|
||||
|
||||
TEST: basic usage (myTag)
|
||||
</myTag>
|
||||
|
||||
TEST: basic usage with a namespaced tag (myNs:myTag)
|
||||
</myNs:myTag>
|
||||
@@ -0,0 +1,124 @@
|
||||
--TEST--
|
||||
XML_Util::createStartElement() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createStartElement() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag only" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar")
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag only, passing '' as attribute arg" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
'myNs:myTag',
|
||||
''
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes and namespace" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with empty attributes, whose namespaceUri is not a full namespace" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
'myTag',
|
||||
'',
|
||||
'foo'
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, and multiline = true" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' '
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' ',
|
||||
'^'
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
||||
echo XML_Util::createStartElement(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"http://www.w3c.org/myNs#",
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
false
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createStartElement() basic tests=====
|
||||
|
||||
TEST: tag only
|
||||
<myNs:myTag>
|
||||
|
||||
TEST: tag with attributes
|
||||
<myNs:myTag foo="bar">
|
||||
|
||||
TEST: tag only, passing '' as attribute arg
|
||||
<myNs:myTag>
|
||||
|
||||
TEST: tag with attributes and namespace
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with empty attributes, whose namespaceUri is not a full namespace
|
||||
<myTag xmlns="foo">
|
||||
|
||||
TEST: tag with attributes, namespace, and multiline = true
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'
|
||||
<myNs:myTag foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true
|
||||
<myNs:myTag boo="baz"^ foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
|
||||
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false
|
||||
<myNs:myTag foo="bar"^ boo="baz"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
||||
155
database/php/tests/XML_Util/tests/testBasic_createTag.phpt
Normal file
155
database/php/tests/XML_Util/tests/testBasic_createTag.phpt
Normal file
@@ -0,0 +1,155 @@
|
||||
--TEST--
|
||||
XML_Util::createTag() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createTag() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar")
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute and content" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, and namespace" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag",
|
||||
"http://www.w3c.org/myNs#"
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, and REPLACE_ENTITIES" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, and CDATA_SECTION" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_CDATA_SECTION
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = false" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
false
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = true" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' '
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' ',
|
||||
'^'
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
true
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
||||
echo XML_Util::createTag(
|
||||
"myNs:myTag",
|
||||
array("foo" => "bar", "boo" => "baz"),
|
||||
"This is inside the tag and has < & @ > in it",
|
||||
"http://www.w3c.org/myNs#",
|
||||
XML_UTIL_REPLACE_ENTITIES,
|
||||
true,
|
||||
' ',
|
||||
'^',
|
||||
false
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createTag() basic tests=====
|
||||
|
||||
TEST: tag with attribute
|
||||
<myNs:myTag foo="bar" />
|
||||
|
||||
TEST: tag with attribute and content
|
||||
<myNs:myTag foo="bar">This is inside the tag</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, and namespace
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, and REPLACE_ENTITIES
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, and CDATA_SECTION
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#"><![CDATA[This is inside the tag and has < & @ > in it]]></myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = false
|
||||
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, and multiline = true
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)
|
||||
<myNs:myTag foo="bar"
|
||||
xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'
|
||||
<myNs:myTag foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true
|
||||
<myNs:myTag boo="baz"^ foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
|
||||
TEST: tag with attribute, content, namespace, REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false
|
||||
<myNs:myTag foo="bar"^ boo="baz"^ xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag>
|
||||
@@ -0,0 +1,203 @@
|
||||
--TEST--
|
||||
XML_Util::createTagFromArray() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::createTagFromArray() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$bad = array(
|
||||
"foo" => "bar",
|
||||
);
|
||||
$tag1 = array(
|
||||
"qname" => "foo:bar",
|
||||
);
|
||||
$tag2 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
);
|
||||
$tag3 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
);
|
||||
$tag4 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
$tag5 = array(
|
||||
"qname" => "foo:bar",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
$tag6 = array(
|
||||
"qname" => "foo:bar",
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
$tag7 = array(
|
||||
"namespaceUri" => "http://foo.com",
|
||||
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
|
||||
"content" => "I'm inside the tag",
|
||||
);
|
||||
|
||||
$tag8 = array(
|
||||
'content' => array('foo', 'bar')
|
||||
);
|
||||
|
||||
$tag9 = array(
|
||||
'qname' => 'foo:bar',
|
||||
'namespaces' => array('ns1' => 'uri1', 'ns2' => 'uri2')
|
||||
);
|
||||
|
||||
$tag10 = array(
|
||||
'namespace' => 'http://foo.org',
|
||||
'localPart' => 'bar'
|
||||
);
|
||||
|
||||
$tag11 = array(
|
||||
'namespace' => '',
|
||||
'localPart' => 'bar'
|
||||
);
|
||||
|
||||
$tag12 = array(
|
||||
'localPart' => 'foo',
|
||||
'namespaceUri' => 'http://bar.org'
|
||||
);
|
||||
|
||||
echo "TEST: basic usage with an invalid array" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($bad) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname only)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag1) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname and namespaceUri)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag2) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, and attributes)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag3) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, attributes, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag5) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag6) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (namespaceUri, attributes, and content)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag7) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus REPLACE_ENTITIES" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus ENTITIES_NONE" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_ENTITIES_NONE) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = false" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = true" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^', true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag4, XML_UTIL_REPLACE_ENTITIES, true, ' ', '^', false) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: cause a non-scalar error on the content tag' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag8) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: handle an array of namespaces being passed' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag9) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: qname is derived from namespace + localPart' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag10) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: qname is derived from localPart only' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag11) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'TEST: namespaceUri is given, but namespace is not' . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($tag12) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::createTagFromArray() basic tests=====
|
||||
|
||||
TEST: basic usage with an invalid array
|
||||
You must either supply a qualified name (qname) or local tag name (localPart).
|
||||
|
||||
TEST: basic usage with a valid array (qname only)
|
||||
<foo:bar />
|
||||
|
||||
TEST: basic usage with a valid array (qname and namespaceUri)
|
||||
<foo:bar xmlns:foo="http://foo.com" />
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, and attributes)
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com" />
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content)
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, attributes, and content)
|
||||
<foo:bar argh="fruit&vegetable" key="value">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, and content)
|
||||
<foo:bar xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (namespaceUri, attributes, and content)
|
||||
You must either supply a qualified name (qname) or local tag name (localPart).
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus REPLACE_ENTITIES
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), plus ENTITIES_NONE
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = false
|
||||
<foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, and multiline = true
|
||||
<foo:bar argh="fruit&vegetable"
|
||||
key="value"
|
||||
xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, and indent = (2 spaces)
|
||||
<foo:bar argh="fruit&vegetable"
|
||||
key="value"
|
||||
xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), and linebreak = '^'
|
||||
<foo:bar argh="fruit&vegetable"^ key="value"^ xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = true
|
||||
<foo:bar argh="fruit&vegetable"^ key="value"^ xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: basic usage with a valid array (qname, namespaceUri, attributes, and content), REPLACE_ENTITIES, multiline = true, indent = (2 spaces), linebreak = '^', and sortAttributes = false
|
||||
<foo:bar key="value"^ argh="fruit&vegetable"^ xmlns:foo="http://foo.com">I'm inside the tag</foo:bar>
|
||||
|
||||
TEST: cause a non-scalar error on the content tag
|
||||
Supplied non-scalar value as tag content
|
||||
|
||||
TEST: handle an array of namespaces being passed
|
||||
<foo:bar xmlns:ns1="uri1" xmlns:ns2="uri2" />
|
||||
|
||||
TEST: qname is derived from namespace + localPart
|
||||
<http://foo.org:bar />
|
||||
|
||||
TEST: qname is derived from localPart only
|
||||
<bar />
|
||||
|
||||
TEST: namespaceUri is given, but namespace is not
|
||||
<foo xmlns="http://bar.org" />
|
||||
@@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
XML_Util::getDocTypeDeclaration() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::getDocTypeDeclaration() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using root only" . PHP_EOL;
|
||||
echo XML_Util::getDocTypeDeclaration("rootTag") . PHP_EOL . 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=====
|
||||
|
||||
TEST: using root only
|
||||
<!DOCTYPE rootTag>
|
||||
|
||||
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" [
|
||||
<!ELEMENT additionalInfo (#PCDATA)>
|
||||
]>
|
||||
@@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
XML_Util::getXmlDeclaration() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::getXmlDeclaration() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version only" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version and encoding" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0", "UTF-8") . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version, encoding, and standalone flag" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0", "UTF-8", true) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: using version and standalone flag" . PHP_EOL;
|
||||
echo XML_Util::getXMLDeclaration("1.0", null, true) . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::getXmlDeclaration() basic tests=====
|
||||
|
||||
TEST: using version only
|
||||
<?xml version="1.0"?>
|
||||
|
||||
TEST: using version and encoding
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
TEST: using version, encoding, and standalone flag
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
TEST: using version and standalone flag
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
46
database/php/tests/XML_Util/tests/testBasic_isValidName.phpt
Normal file
46
database/php/tests/XML_Util/tests/testBasic_isValidName.phpt
Normal file
@@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
XML_Util::isValidName() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::isValidName() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: valid tag" . PHP_EOL;
|
||||
$result = XML_Util::isValidName("alpha-x_y_z.123");
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
|
||||
} else {
|
||||
print "Valid XML name." . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
echo "TEST: invalid tag" . PHP_EOL;
|
||||
$result = XML_Util::isValidName("invalidTag?");
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
|
||||
} else {
|
||||
print "Valid XML name." . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
echo "TEST: invalid tag that doesn't start with a letter" . PHP_EOL;
|
||||
$result = XML_Util::isValidName("1234five");
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
|
||||
} else {
|
||||
print "Valid XML name." . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::isValidName() basic tests=====
|
||||
|
||||
TEST: valid tag
|
||||
Valid XML name.
|
||||
|
||||
TEST: invalid tag
|
||||
Invalid XML name: XML names may only contain alphanumeric chars, period, hyphen, colon and underscores
|
||||
|
||||
TEST: invalid tag that doesn't start with a letter
|
||||
Invalid XML name: XML names may only start with letter or underscore
|
||||
19
database/php/tests/XML_Util/tests/testBasic_raiseError.phpt
Normal file
19
database/php/tests/XML_Util/tests/testBasic_raiseError.phpt
Normal file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
XML_Util::raiseError() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::raiseError() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$error = XML_Util::raiseError("I am an error", 12345);
|
||||
if (is_a($error, 'PEAR_Error')) {
|
||||
print "PEAR Error: " . $error->getMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::raiseError() basic tests=====
|
||||
|
||||
PEAR Error: I am an error
|
||||
@@ -0,0 +1,82 @@
|
||||
--TEST--
|
||||
XML_Util::replaceEntities() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::replaceEntities() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$data = 'This string contains < & >.';
|
||||
$utf8 = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
||||
|
||||
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;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::replaceEntities() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage but with bogus $replaceEntities arg
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_HTML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
--TEST--
|
||||
XML_Util::reverseEntities() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::reverseEntities() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$data = 'This string contains < & >.';
|
||||
$utf8 = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
||||
|
||||
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;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: utf8 usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
|
||||
echo XML_Util::reverseEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::reverseEntities() basic tests=====
|
||||
|
||||
TEST: basic usage
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage but with bogus $replaceEntities arg
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_XML_REQUIRED and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML
|
||||
This string contains < & >.
|
||||
|
||||
TEST: basic usage with ENTITIES_HTML and UTF-8
|
||||
This string contains < & >.
|
||||
|
||||
TEST: utf8 usage with ENTITIES_HTML and UTF-8
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
XML_Util::splitQualifiedName() basic tests
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util::splitQualifiedName() basic tests=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage without namespace" . PHP_EOL;
|
||||
$return = XML_Util::splitQualifiedName("xslt:stylesheet");
|
||||
echo "namespace => " . $return['namespace'] . PHP_EOL;
|
||||
echo "localPart => " . $return['localPart'] . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
|
||||
echo "TEST: basic usage with namespace" . PHP_EOL;
|
||||
$return = XML_Util::splitQualifiedName("stylesheet", "myNs");
|
||||
echo "namespace => " . $return['namespace'] . PHP_EOL;
|
||||
echo "localPart => " . $return['localPart'] . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util::splitQualifiedName() basic tests=====
|
||||
|
||||
TEST: basic usage without namespace
|
||||
namespace => xslt
|
||||
localPart => stylesheet
|
||||
|
||||
TEST: basic usage with namespace
|
||||
namespace => myNs
|
||||
localPart => stylesheet
|
||||
62
database/php/tests/XML_Util/tests/testBug_18343.phpt
Normal file
62
database/php/tests/XML_Util/tests/testBug_18343.phpt
Normal file
@@ -0,0 +1,62 @@
|
||||
--TEST--
|
||||
XML_Util tests for Bug #18343 Entities in file names decoded during packaging
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.2a1 2014-06-03
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util tests for Bug #18343 "Entities in file names decoded during packaging"=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: test case provided in bug report" . PHP_EOL;
|
||||
$array = array(
|
||||
"qname" => "install",
|
||||
"attributes" => array(
|
||||
"as" => "Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek",
|
||||
"name" => "test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek",
|
||||
)
|
||||
);
|
||||
|
||||
echo "No matter what flags are given to createTagFromArray(), an attribute must *always* be at least ENTITIES_XML encoded..." . PHP_EOL . PHP_EOL;
|
||||
|
||||
$flags = array(
|
||||
'no flag' => null,
|
||||
'false' => false,
|
||||
'ENTITIES_NONE' => XML_UTIL_ENTITIES_NONE,
|
||||
'ENTITIES_XML' => XML_UTIL_ENTITIES_XML,
|
||||
'ENTITIES_XML_REQUIRED' => XML_UTIL_ENTITIES_XML_REQUIRED,
|
||||
'ENTITIES_HTML' => XML_UTIL_ENTITIES_HTML,
|
||||
'REPLACE_ENTITIES' => XML_UTIL_REPLACE_ENTITIES,
|
||||
);
|
||||
foreach ($flags as $flagKey => $flagValue) {
|
||||
echo "Testing with $flagKey:" . PHP_EOL;
|
||||
echo XML_Util::createTagFromArray($array, $flagValue) . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util tests for Bug #18343 "Entities in file names decoded during packaging"=====
|
||||
|
||||
TEST: test case provided in bug report
|
||||
No matter what flags are given to createTagFromArray(), an attribute must *always* be at least ENTITIES_XML encoded...
|
||||
|
||||
Testing with no flag:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with false:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_NONE:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_XML:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_XML_REQUIRED:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with ENTITIES_HTML:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
Testing with REPLACE_ENTITIES:
|
||||
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" />
|
||||
|
||||
21
database/php/tests/XML_Util/tests/testBug_4950.phpt
Normal file
21
database/php/tests/XML_Util/tests/testBug_4950.phpt
Normal file
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
XML_Util tests for Bug #4950 "Incorrect CDATA serializing"
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util tests for Bug #4950 "Incorrect CDATA serializing"=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: test case provided in bug report" . PHP_EOL;
|
||||
echo XML_Util::createTag("test", array(), "Content ]]></test> here!",
|
||||
null, XML_UTIL_CDATA_SECTION) . PHP_EOL;
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util tests for Bug #4950 "Incorrect CDATA serializing"=====
|
||||
|
||||
TEST: test case provided in bug report
|
||||
<test><![CDATA[Content ]]]]><![CDATA[></test> here!]]></test>
|
||||
|
||||
27
database/php/tests/XML_Util/tests/testBug_5392.phpt
Normal file
27
database/php/tests/XML_Util/tests/testBug_5392.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
XML_Util tests for Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"
|
||||
--CREDITS--
|
||||
Chuck Burgess <ashnazg@php.net>
|
||||
# created for v1.2.0a1 2008-05-04
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
||||
echo '=====XML_Util tests for Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"=====' . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo "TEST: test case provided in bug report" . PHP_EOL;
|
||||
$data = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
||||
|
||||
$replaced = XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8');
|
||||
|
||||
$reversed = XML_Util::reverseEntities($replaced, XML_UTIL_ENTITIES_HTML, 'UTF-8');
|
||||
|
||||
echo $replaced . PHP_EOL;
|
||||
echo $reversed . PHP_EOL;
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
=====XML_Util tests for Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"=====
|
||||
|
||||
TEST: test case provided in bug report
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê
|
||||
Reference in New Issue
Block a user