cvs: pear /XML_Util/tests AllTests.php testBasic_apiVersion.phpt testBasic_attributesToString.phpt testBasic_collapseEmptyTags.phpt testBasic_createCDataSection.phpt testBasic_createComment.phpt testBasic_createEndElement.phpt testBasic_createStartElement.phpt testBasic_createTag.phpt testBasic_createTagFromArray.phpt testBasic_getDocTypeDeclaration.phpt testBasic_getXmlDeclaration.phpt testBasic_isValidName.phpt testBasic_raiseError.phpt testBasic_replaceEntities.phpt testBasic_reverseEntities.phpt testBasic_splitQualifiedName.phpt
[email protected] ("Chuck Burgess") Sun, 04 May 2008 15:21:53 -0000
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvsashnazg1209914513@cvsserver> |
ashnazg Sun May 4 15:21:53 2008 UTC
Added files:
/pear/XML_Util/tests AllTests.php testBasic_apiVersion.phpt
testBasic_attributesToString.phpt
testBasic_collapseEmptyTags.phpt
testBasic_createCDataSection.phpt
testBasic_createComment.phpt
testBasic_createEndElement.phpt
testBasic_createStartElement.phpt
testBasic_createTag.phpt
testBasic_createTagFromArray.phpt
testBasic_getDocTypeDeclaration.phpt
testBasic_getXmlDeclaration.phpt
testBasic_isValidName.phpt
testBasic_raiseError.phpt
testBasic_replaceEntities.phpt
testBasic_reverseEntities.phpt
testBasic_splitQualifiedName.phpt
Log:
adding a test suite to this package
ashnazg-20080504152153.txt
(text/plain, 33.4 KB)
http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/AllTests.php?view=markup&rev=1.1 Index: pear/XML_Util/tests/AllTests.php +++ pear/XML_Util/tests/AllTests.php <?php /** * Master Unit Test Suite file for XML_Util * * This top-level test suite file organizes * all class test suite files, * so that the full suite can be run * by PhpUnit or via "pear run-tests -u". * * PHP versions 4 and 5 * * @category XML * @package Util * @subpackage UnitTesting * @author Chuck Burgess <[email protected]> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @version CVS: $Id: AllTests.php,v 1.1 2008/05/04 15:21:52 ashnazg Exp $ * @link http://pear.php.net/package/XML_Util * @since 1.1.5 */ /** * Check PHP version... PhpUnit v3+ requires at least PHP v5.1.4 */ if (version_compare(PHP_VERSION, "5.1.4") < 0) { // Cannnot run test suites echo "Cannot run test suites... requires at least PHP v5.1.4.\n"; exit(1); } /** * Derive the "main" method name * @internal PhpUnit would have to rename PHPUnit_MAIN_METHOD to PHPUNIT_MAIN_METHOD * to make this usage meet the PEAR CS... we cannot rename it here. */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'XML_Util_AllTests::main'); } /* * Files needed by PhpUnit */ require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; /* * You must add each additional class-level test suite file here */ // there are no PhpUnit test files... only PHPTs.. so nothing is listed here /** * Master Unit Test Suite class for XML_Util * * This top-level test suite class organizes * all class test suite files, * so that the full suite can be run * by PhpUnit or via "pear run-tests -u". * * @category XML * @package Util * @subpackage UnitTesting * @author Chuck Burgess <[email protected]> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @version Release: @package_version@ * @link http://pear.php.net/package/XML_Util * @since 1.1.5 */ class XML_Util_AllTests { /** * Launches the TextUI test runner * * @return void * @uses PHPUnit_TextUI_TestRunner */ public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); } /** * Adds all class test suites into the master suite * * @return PHPUnit_Framework_TestSuite a master test suite * containing all class test suites * @uses PHPUnit_Framework_TestSuite */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite( 'XML_Util Full Suite of Unit Tests'); /* * You must add each additional class-level test suite name here */ // there are no PhpUnit test files... only PHPTs.. so nothing is listed here return $suite; } } /** * Call the main method if this file is executed directly * @internal PhpUnit would have to rename PHPUnit_MAIN_METHOD to PHPUNIT_MAIN_METHOD * to make this usage meet the PEAR CS... we cannot rename it here. */ if (PHPUnit_MAIN_METHOD == 'XML_Util_AllTests::main') { XML_Util_AllTests::main(); } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ ?> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_apiVersion.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_apiVersion.phpt +++ pear/XML_Util/tests/testBasic_apiVersion.phpt --TEST-- XML_Util::apiVersion() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; echo "TEST: basic apiVersion() call" . PHP_EOL; echo XML_Util::apiVersion() . PHP_EOL; ?> --EXPECT-- TEST: basic apiVersion() call 1.1 http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_attributesToString.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_attributesToString.phpt +++ pear/XML_Util/tests/testBasic_attributesToString.phpt --TEST-- XML_Util::attributesToString() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; $att = array("foo" => "bar", "boo" => "baz"); 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: 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-- 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: 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" http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_collapseEmptyTags.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_collapseEmptyTags.phpt +++ pear/XML_Util/tests/testBasic_collapseEmptyTags.phpt --TEST-- XML_Util::collapseEmptyTags() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; $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-- 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> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_createCDataSection.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_createCDataSection.phpt +++ pear/XML_Util/tests/testBasic_createCDataSection.phpt --TEST-- XML_Util::createCDataSection() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; echo "TEST: basic usage" . PHP_EOL; echo XML_Util::createCDataSection("I am content.") . PHP_EOL; ?> --EXPECT-- TEST: basic usage <![CDATA[I am content.]]> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_createComment.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_createComment.phpt +++ pear/XML_Util/tests/testBasic_createComment.phpt --TEST-- XML_Util::createComment() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; echo "TEST: basic usage" . PHP_EOL; echo XML_Util::createComment("I am comment.") . PHP_EOL; ?> --EXPECT-- TEST: basic usage <!-- I am comment. --> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_createEndElement.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_createEndElement.phpt +++ pear/XML_Util/tests/testBasic_createEndElement.phpt --TEST-- XML_Util::createEndElement() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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-- TEST: basic usage (myTag) </myTag> TEST: basic usage with a namespaced tag (myNs:myTag) </myNs:myTag> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_createStartElement.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_createStartElement.phpt +++ pear/XML_Util/tests/testBasic_createStartElement.phpt --TEST-- XML_Util::createStartElement() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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 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 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-- TEST: tag only <myNs:myTag> TEST: tag with attributes <myNs:myTag foo="bar"> TEST: tag with attributes and namespace <myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#"> 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#"> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_createTag.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_createTag.phpt +++ pear/XML_Util/tests/testBasic_createTag.phpt --TEST-- XML_Util::createTag() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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-- 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> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_createTagFromArray.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_createTagFromArray.phpt +++ pear/XML_Util/tests/testBasic_createTagFromArray.phpt --TEST-- XML_Util::createTagFromArray() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; $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", ); 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; ?> --EXPECT-- 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> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_getDocTypeDeclaration.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_getDocTypeDeclaration.phpt +++ pear/XML_Util/tests/testBasic_getDocTypeDeclaration.phpt --TEST-- XML_Util::getDocTypeDeclaration() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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 XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd") . PHP_EOL . PHP_EOL; ?> --EXPECT-- TEST: using root only <!DOCTYPE rootTag> TEST: using root and URI <!DOCTYPE rootTag SYSTEM "myDocType.dtd"> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_getXmlDeclaration.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_getXmlDeclaration.phpt +++ pear/XML_Util/tests/testBasic_getXmlDeclaration.phpt --TEST-- XML_Util::getXmlDeclaration() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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-- 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"?> http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_isValidName.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_isValidName.phpt +++ pear/XML_Util/tests/testBasic_isValidName.phpt --TEST-- XML_Util::isValidName() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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; } ?> --EXPECT-- TEST: valid tag Valid XML name. TEST: invalid tag Invalid XML name: XML names may only contain alphanumeric chars, period, hyphen, colon and underscores http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_raiseError.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_raiseError.phpt +++ pear/XML_Util/tests/testBasic_raiseError.phpt --TEST-- XML_Util::raiseError() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; $error = XML_Util::raiseError("I am an error", 12345); if (is_a($error, 'PEAR_Error')) { print "PEAR Error: " . $error->getMessage() . PHP_EOL; } ?> --EXPECT-- PEAR Error: I am an error http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_replaceEntities.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_replaceEntities.phpt +++ pear/XML_Util/tests/testBasic_replaceEntities.phpt --TEST-- XML_Util::replaceEntities() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; echo "TEST: basic usage" . PHP_EOL; echo XML_Util::replaceEntities("This string contains < & >.") . PHP_EOL . PHP_EOL; echo "TEST: basic usage with ENTITIES_XML" . PHP_EOL; echo XML_Util::replaceEntities("This string contains < & >.", XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL; echo "TEST: basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL; echo XML_Util::replaceEntities("This string contains < & >.", XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL; echo "TEST: basic usage with ENTITIES_HTML" . PHP_EOL; echo XML_Util::replaceEntities("This string contains < & >.", XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL; ?> --EXPECT-- TEST: basic usage This string contains < & >. TEST: basic usage with ENTITIES_XML This string contains < & >. TEST: basic usage with ENTITIES_XML_REQUIRED This string contains < & >. TEST: basic usage with ENTITIES_HTML This string contains < & >. http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_reverseEntities.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_reverseEntities.phpt +++ pear/XML_Util/tests/testBasic_reverseEntities.phpt --TEST-- XML_Util::reverseEntities() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; echo "TEST: basic usage" . PHP_EOL; echo XML_Util::reverseEntities("This string contains < & >.") . PHP_EOL . PHP_EOL; echo "TEST: basic usage with ENTITIES_XML" . PHP_EOL; echo XML_Util::reverseEntities("This string contains < & >.", XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL; echo "TEST: basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL; echo XML_Util::reverseEntities("This string contains < & >.", XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL; echo "TEST: basic usage with ENTITIES_HTML" . PHP_EOL; echo XML_Util::reverseEntities("This string contains < & >.", XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL; ?> --EXPECT-- TEST: basic usage This string contains < & >. TEST: basic usage with ENTITIES_XML This string contains < & >. TEST: basic usage with ENTITIES_XML_REQUIRED This string contains < & >. TEST: basic usage with ENTITIES_HTML This string contains < & >. http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBasic_splitQualifiedName.phpt?view=markup&rev=1.1 Index: pear/XML_Util/tests/testBasic_splitQualifiedName.phpt +++ pear/XML_Util/tests/testBasic_splitQualifiedName.phpt --TEST-- XML_Util::splitQualifiedName() basic tests --FILE-- <?php require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php'; 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-- TEST: basic usage without namespace namespace => xslt localPart => stylesheet TEST: basic usage with namespace namespace => myNs localPart => stylesheet