* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
* @link http://pear.php.net/package/XML_Util
*/
/**
* set error level
*/
error_reporting(E_ALL);
require_once 'XML/Util.php';
/**
* replacing XML entities
*/
print 'replace XML entities:
';
print XML_Util::replaceEntities('This string contains < & >.');
print "\n
\n";
/**
* reversing XML entities
*/
print 'replace XML entities:
';
print XML_Util::reverseEntities('This string contains < & >.');
print "\n
\n";
/**
* building XML declaration
*/
print 'building XML declaration:
';
print htmlspecialchars(XML_Util::getXMLDeclaration());
print "\n
\n";
print 'building XML declaration with additional attributes:
';
print htmlspecialchars(XML_Util::getXMLDeclaration('1.0', 'UTF-8', true));
print "\n
\n";
/**
* building document type declaration
*/
print 'building DocType declaration:
';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
'http://pear.php.net/dtd/package-1.0'));
print "\n
\n";
print 'building DocType declaration with public ID (does not exist):
';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
array('uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1')));
print "\n
\n";
print 'building DocType declaration with internal DTD:
';
print '';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
'http://pear.php.net/dtd/package-1.0',
''));
print '
';
print "\n
\n";
/**
* creating an attribute string
*/
$att = array(
'foo' => 'bar',
'argh' => 'tomato'
);
print 'converting array to string:
';
print XML_Util::attributesToString($att);
print "\n
\n";
/**
* creating an attribute string with linebreaks
*/
$att = array(
'foo' => 'bar',
'argh' => 'tomato'
);
print 'converting array to string (including line breaks):
';
print '';
print XML_Util::attributesToString($att, true, true);
print '
';
print "\n
\n";
/**
* splitting a qualified tag name
*/
print 'splitting qualified tag name:
';
print '';
print_r(XML_Util::splitQualifiedName('xslt:stylesheet'));
print '
';
print "\n
\n";
/**
* splitting a qualified tag name (no namespace)
*/
print 'splitting qualified tag name (no namespace):
';
print '';
print_r(XML_Util::splitQualifiedName('foo'));
print '
';
print "\n
\n";
/**
* splitting a qualified tag name (no namespace, but default namespace specified)
*/
print 'splitting qualified tag name '
. '(no namespace, but default namespace specified):
';
print '';
print_r(XML_Util::splitQualifiedName('foo', 'bar'));
print '
';
print "\n
\n";
/**
* verifying XML names
*/
print 'verifying \'My private tag\':
';
print '';
print_r(XML_Util::isValidname('My Private Tag'));
print '
';
print "\n
\n";
print 'verifying \'-MyTag\':
';
print '';
print_r(XML_Util::isValidname('-MyTag'));
print '
';
print "\n
\n";
/**
* creating an XML tag
*/
$tag = array(
'namespace' => 'foo',
'localPart' => 'bar',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag'
);
print 'creating a tag with namespace and local part:
';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n
\n";
/**
* creating an XML tag
*/
$tag = array(
'qname' => 'foo:bar',
'namespaceUri' => 'http://foo.com',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag'
);
print 'creating a tag with qualified name and namespaceUri:
';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n
\n";
/**
* creating an XML tag
*/
$tag = array(
'qname' => 'bar',
'namespaceUri' => 'http://foo.com',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable')
);
print 'creating an empty tag without namespace but namespace Uri:
';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n
\n";
/**
* creating an XML tag with more namespaces
*/
$tag = array(
'namespace' => 'foo',
'localPart' => 'bar',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag',
'namespaces' => array(
'bar' => 'http://bar.com',
'pear' => 'http://pear.php.net',
)
);
print 'creating an XML tag with more namespaces:
';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n
\n";
/**
* creating an XML tag with a CData Section
*/
$tag = array(
'qname' => 'foo',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag'
);
print 'creating a tag with CData section:
';
print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_CDATA_SECTION));
print "\n
\n";
/**
* creating an XML tag with a CData Section
*/
$tag = array(
'qname' => 'foo',
'attributes' => array('key' => 'value', 'argh' => 'tt'),
'content' =>
'Also XHTML-tags can be created '
. 'and HTML entities can be replaced <>.'
);
print 'creating a tag with HTML entities:
';
print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_ENTITIES_HTML));
print "\n
\n";
/**
* creating an XML tag with createTag
*/
print 'creating a tag with createTag:
';
print htmlentities(XML_Util::createTag('myNs:myTag',
array('foo' => 'bar'),
'This is inside the tag',
'http://www.w3c.org/myNs#'));
print "\n
\n";
/**
* trying to create an XML tag with an array as content
*/
$tag = array(
'qname' => 'bar',
'content' => array('foo' => 'bar')
);
print 'trying to create an XML tag with an array as content:
';
print '';
print_r(XML_Util::createTagFromArray($tag));
print '
';
print "\n
\n";
/**
* trying to create an XML tag without a name
*/
$tag = array(
'attributes' => array('foo' => 'bar'),
);
print 'trying to create an XML tag without a name:
';
print '';
print_r(XML_Util::createTagFromArray($tag));
print '
';
print "\n
\n";
?>
PK eqYیu tests/ApiVersionTests.phpnu [ assertEquals('1.4', XML_Util::apiVersion());
}
}PK eqY~$[e e tests/CreateEndElementTests.phpnu [ ";
$this->assertEquals($expected, XML_Util::createEndElement($original));
}
/**
* @covers XML_Util::createEndElement()
*/
public function testCreateEndElementWithNamespacedTag()
{
$original = "myNs:myTag";
$expected = "";
$this->assertEquals($expected, XML_Util::createEndElement($original));
}
}
PK eqYDf: tests/GetXmlDeclarationTests.phpnu [ ";
$this->assertEquals($expected, XML_Util::getXMLDeclaration($version));
}
/**
* @covers XML_Util::getXMLDeclaration()
*/
public function testGetXMLDeclarationUsingVersionAndEncodingAndStandalone()
{
$version = "1.0";
$encoding = "UTF-8";
$standalone = true;
$expected = "";
$this->assertEquals($expected, XML_Util::getXMLDeclaration($version, $encoding, $standalone));
}
/**
* @covers XML_Util::getXMLDeclaration()
*/
public function testGetXMLDeclarationUsingVersionAndStandalone()
{
$version = "1.0";
$encoding = null;
$standalone = true;
$expected = "";
$this->assertEquals($expected, XML_Util::getXMLDeclaration($version, $encoding, $standalone));
}
}
PK eqYT T tests/CreateCommentTests.phpnu [ ";
$this->assertEquals($expected, XML_Util::createComment($original));
}
}
PK eqYG tests/Bug21177Tests.phpnu [ ';
return array(
array('', ''),
array('', ''),
array('', ''),
array('', ''),
);
}
/**
* @dataProvider getTestCandidate()
*/
public function testCollapseEmptyTagsForBug21177($original, $expected)
{
$this->assertEquals($expected, XML_Util::collapseEmptyTags($original, XML_UTIL_COLLAPSE_ALL), "Failed bugcheck.");
}
}
PK eqYYq tests/Bug21184Tests.phpnu [ one';
$this->assertEquals($xml, XML_Util::collapseEmptyTags($xml, XML_UTIL_COLLAPSE_ALL));
}
}
PK eqY|\5 tests/CollapseEmptyTagsTests.phpnu [ ";
$expected = "";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsBasicUsageAlongsideNonemptyTag()
{
$emptyTag = "";
$otherTag = "baz";
$expected = "baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseAll()
{
$emptyTag = "";
$expected = "";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseAll()
{
$emptyTag = "";
$otherTag = "baz";
$expected = "baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagAlongsideEmptyTagWithCollapseAll()
{
$emptyTag = "";
$otherTag = "baz";
$expected = "baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyPrefixedTagAlongsideNonemptyTagAlongsideEmptyPrefixedTagWithCollapseAll()
{
$emptyTag = "";
$otherTag = "baz";
$expected = "baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyNsPrefixedTagAlongsideNonemptyTagAlongsideEmptyNsPrefixedTagWithCollapseAll()
{
$emptyTag = "";
$otherTag = "baz";
$expected = "baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseXhtml()
{
$emptyTag = "";
$expected = "";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_XHTML_ONLY));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseXhtml()
{
$emptyTag = "";
$otherTag = "baz";
$xhtmlTag = "
";
$expected = "
baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL_COLLAPSE_XHTML_ONLY));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseNone()
{
$emptyTag = "";
$expected = "";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_NONE));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseNone()
{
$emptyTag = "";
$otherTag = "baz";
$expected = "baz";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_NONE));
}
}
PK eqYG G ! tests/SplitQualifiedNameTests.phpnu [ 'xslt',
'localPart' => 'stylesheet',
);
$this->assertEquals($expected, XML_Util::splitQualifiedName($original));
}
/**
* @covers XML_Util::splitQualifiedName()
*/
public function testSplitQualifiedNameWithNamespace()
{
$original = "stylesheet";
$namespace = "myNs";
$expected = array(
'namespace' => 'myNs',
'localPart' => 'stylesheet',
);
$this->assertEquals($expected, XML_Util::splitQualifiedName($original, $namespace));
}
}
PK eqYzt tests/ReverseEntitiesTests.phpnu [ .";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData()));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), 'INVALID_OPTION'));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXml()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML), $encoding);
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForUtf8DataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML), $encoding);
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequired()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesHtml()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForUtf8DataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding));
}
}
PK eqYܬ$ $ tests/GetDocTypeDeclarationTests.phpnu [ ";
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag"));
}
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRootAndStringUri()
{
$expected = "";
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd"));
}
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRootAndArrayUri()
{
$uri = array(
'uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
);
$expected = "";
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", $uri));
}
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRootAndArrayUriAndInternalDtd()
{
$uri = array(
'uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
);
$dtdEntry = '';
$expected =
<<< EOF
]>
EOF;
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", $uri, $dtdEntry));
}
}
PK eqY۩ tests/Bug18343Tests.phpnu [ "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",
)
);
public function getFlagsToTest()
{
new XML_Util(); // for constants to be declared
return array(
array('no flag', null),
array('false', false),
array('ENTITIES_NONE', XML_UTIL_ENTITIES_NONE),
array('ENTITIES_XML', XML_UTIL_ENTITIES_XML),
array('ENTITIES_XML_REQUIRED', XML_UTIL_ENTITIES_XML_REQUIRED),
array('ENTITIES_HTML', XML_UTIL_ENTITIES_HTML),
array('REPLACE_ENTITIES', XML_UTIL_REPLACE_ENTITIES),
);
}
/**
* @dataProvider getFlagsToTest()
*/
public function testCreateTagFromArrayForBug18343($key, $flag)
{
// all flags for the candidate input should return the same result
$expected =
<<< EOF
EOF;
$this->assertEquals($expected, XML_Util::createTagFromArray($this->tagArray, $flag), "Failed bugcheck for $key.");
}
}
PK eqY>M tests/Bug4950Tests.phpnu [ here!";
$namespaceUrl = null;
$expected = " here!]]>";
$result = XML_Util::createTag($qname, $attributes, $content, $namespaceUrl, XML_UTIL_CDATA_SECTION);
$this->assertEquals($expected, $result, "Failed bugcheck.");
}
}
PK eqYrv tests/RaiseErrorTests.phpnu [ assertInstanceOf('PEAR_Error', $error);
$this->assertEquals($message, $error->getMessage());
$this->assertEquals($code, $error->getCode());
}
}
PK eqYC tests/ReplaceEntitiesTests.phpnu [ .';
}
protected function getUtf8Data()
{
return 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleData()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData()));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), 'INVALID_OPTION'));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXml()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForUtf8DataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXmlRequired()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesHtml()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForUtf8DataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding));
}
}
PK eqY4ej j ! tests/CreateCDataSectionTests.phpnu [ ";
$this->assertEquals($expected, XML_Util::createCDataSection($original));
}
}
PK eqYe>4 4 ! tests/CreateTagFromArrayTests.phpnu [ "foo:bar",
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespace()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributes()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContent()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndAttributesAndContent()
{
$original = array(
"qname" => "foo:bar",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndContent()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"content" => "I'm inside the tag",
);
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithEntitiesNone()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_ENTITIES_NONE));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntities()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineFalse()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = false;
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrue()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$expected =
<<< EOF
I'm inside the tag
EOF;
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndent()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$expected =
<<< EOF
I'm inside the tag
EOF;
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreak()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$linebreak = "^";
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesTrue()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = true;
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesFalse()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = false;
$expected = "I'm inside the tag";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithInvalidArray()
{
$badArray = array(
"foo" => "bar",
);
$expectedError = "You must either supply a qualified name (qname) or local tag name (localPart).";
$this->assertEquals($expectedError, XML_Util::createTagFromArray($badArray));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithNamespaceAndAttributesAndContentButWithoutQname()
{
$original = array(
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expectedError = "You must either supply a qualified name (qname) or local tag name (localPart).";
$this->assertEquals($expectedError, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithNonScalarContent()
{
$badArray = array(
'content' => array('foo', 'bar'),
);
$expectedError = "Supplied non-scalar value as tag content";
$this->assertEquals($expectedError, XML_Util::createTagFromArray($badArray));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithArrayOfNamespaces()
{
$original = array(
'qname' => 'foo:bar',
'namespaces' => array('ns1' => 'uri1', 'ns2' => 'uri2'),
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameDerivedFromNamespaceUriAndLocalPart()
{
$original = array(
'namespaceUri' => 'http://bar.org',
'localPart' => 'foo'
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameDerivedFromNamespaceAndLocalPart()
{
$original = array(
'namespace' => 'http://foo.org',
'localPart' => 'bar'
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameDerivedFromLocalPart()
{
$original = array(
'namespace' => '',
'localPart' => 'bar'
);
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithImplicitlyEmptyContentAndCollapseNoneDoesNotCollapseTag()
{
$original = array('qname' => 'tag1');
$expected = "";
$actual = XML_Util::createTagFromArray(
$original,
XML_UTIL_REPLACE_ENTITIES, // default $replaceEntities
false, // default $multiline
'_auto', // default $indent
"\n", // default $linebreak
true, // default $sortAttributes
XML_UTIL_COLLAPSE_NONE
);
$this->assertEquals($expected, $actual);
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayForCdataWithExplicitlyEmptyContentDoesNotCollapseTag()
{
$original = array('qname' => 'tag1', 'content' => '');
$expected = "";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_CDATA_SECTION));
}
}
PK eqYYR" " ! tests/CreateStartElementTests.phpnu [ ";
$this->assertEquals($expected, XML_Util::createStartElement($original));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributes()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$expected = "";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithEmptyAttributes()
{
$originalTag = "myNs:myTag";
$originalAttributes = "";
$expected = "";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespace()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithEmptyAttributesAndNonUriNamespace()
{
$originalTag = "myTag";
$originalAttributes = "";
$originalNamespace = "foo";
$expected = "";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultiline()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected =
<<< EOF
EOF;
$multiline = true;
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndent()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected =
<<< EOF
EOF;
$multiline = true;
$indent = " ";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreak()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "";
$multiline = true;
$indent = " ";
$linebreak = "^";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreakAndSortAttributesIsTrue()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = true;
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreakAndSortAttributesIsFalse()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = false;
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak, $sortAttributes));
}
}
PK eqY! tests/AbstractUnitTests.phpnu [ "bar");
$expected = "";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContent()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag";
$expected = "This is inside the tag";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespace()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag";
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "This is inside the tag";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithCDataSection()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = " in it]]>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_CDATA_SECTION));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntities()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "This is inside the tag and has < & @ > in it";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineFalse()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = false;
$expected = "This is inside the tag and has < & @ > in it";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrue()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$expected =
<<< EOF
This is inside the tag and has < & @ > in it
EOF;
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndent()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$expected =
<<< EOF
This is inside the tag and has < & @ > in it
EOF;
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreak()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$linebreak = "^";
$expected = "This is inside the tag and has < & @ > in it";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesTrue()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = true;
$expected = "This is inside the tag and has < & @ > in it";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesFalse()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = false;
$expected = "This is inside the tag and has < & @ > in it";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
}
PK eqYGs tests/Bug5392Tests.phpnu [ , & and " as well as ä, ö, ß, à and ê';
$replacedResult = XML_Util::replaceEntities($original, XML_UTIL_ENTITIES_HTML, "UTF-8");
$reversedResult = XML_Util::reverseEntities($replacedResult, XML_UTIL_ENTITIES_HTML, "UTF-8");
$this->assertEquals($original, $reversedResult, "Failed bugcheck.");
}
}
PK eqYZt ! tests/AttributesToStringTests.phpnu [ 'bar','boo' => 'baz',);
$expected = " boo=\"baz\" foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitSortTrue()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\" foo=\"bar\"";
$sort = true;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitSortFalse()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " foo=\"bar\" boo=\"baz\"";
$sort = false;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithMultilineFalse()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\" foo=\"bar\"";
$sort = true;
$multiline = false;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithMultilineTrue()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected =
<<< EOF
boo="baz"
foo="bar"
EOF;
$sort = true;
$multiline = true;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitIndent()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\"\n foo=\"bar\"";
$sort = true;
$multiline = true;
$indent = ' '; // 8 spaces
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $indent));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitLinebreak()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\"\n^foo=\"bar\"";
$sort = true;
$multiline = true;
$linebreak = '^'; // some dummy character
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithOptionsThatIncludesSort()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$options = array(
'multiline' => true,
'indent' => '----',
'linebreak' => "^",
'entities' => XML_UTIL_ENTITIES_XML,
'sort' => true,
);
$expected = " boo=\"baz\"\n----foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithOptionsThatExcludesSort()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$options = array(
'multiline' => true,
'indent' => '----',
'linebreak' => "^",
'entities' => XML_UTIL_ENTITIES_XML,
);
$expected = " boo=\"baz\"\n----foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesNone()
{
$original = array("foo" => "b@&r", "boo" => "b>assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_NONE));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesXml()
{
$original = array("foo" => "b@&r", "boo" => "b>assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_XML));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesXmlRequired()
{
$original = array("foo" => "b@&r", "boo" => "b><z\" foo=\"b@&r\"";
$sort = true;
$multiline = false;
$linebreak = ' ';
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_XML_REQUIRED));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesHtml()
{
$original = array("foo" => "b@&r", "boo" => "b>assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_HTML));
}
/**
* Tag attributes should not be treated as CDATA,
* so the operation will instead quietly use XML_UTIL_ENTITIES_XML.
*
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithCDataSectionForSingleAttribute()
{
$original = array('foo' => 'bar'); // need exactly one attribute here
$options = array(
'sort' => true, // doesn't matter for this testcase
'multiline' => false, // doesn't matter for this testcase
'indent' => null, // doesn't matter for this testcase
'linebreak' => null, // doesn't matter for this testcase
'entities' => XML_UTIL_CDATA_SECTION, // DOES matter for this testcase
);
$expected = " foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
/**
* Tag attributes should not be treated as CDATA,
* so the operation will instead quietly use XML_UTIL_ENTITIES_XML.
*
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithCDataSectionForMultipleAttributesAndMultilineFalse()
{
$original = array('foo' => 'bar', 'boo' => 'baz'); // need more than one attribute here
$options = array(
'sort' => true, // doesn't matter for this testcase
'multiline' => false, // DOES matter for this testcase, must be false
'indent' => null, // doesn't matter for this testcase
'linebreak' => null, // doesn't matter for this testcase
'entities' => XML_UTIL_CDATA_SECTION, // DOES matter for this testcase
);
$expected = " boo=\"baz\" foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
}
PK eqYݑh tests/IsValidNameTests.phpnu [ assertTrue($result);
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForTagNameWithInvalidCharacter()
{
$tagName = "invalidTag?";
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only contain alphanumeric chars, period, hyphen, colon and underscores";
$this->assertEquals($expectedError, $result->getMessage());
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForTagNameWithInvalidStartingCharacter()
{
$tagName = "1234five";
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only start with letter or underscore";
$this->assertEquals($expectedError, $result->getMessage());
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForInt()
{
$tagName = 1;
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only start with letter or underscore";
$this->assertEquals($expectedError, $result->getMessage());
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForEmptyString()
{
$tagName = '';
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only start with letter or underscore";
$this->assertEquals($expectedError, $result->getMessage());
}
}
PK {eqYf examples/example2.phpnu [ PK {eqY5k# # 0 examples/example.phpnu [ PK eqYیu <7 tests/ApiVersionTests.phpnu [ PK eqY~$[e e b8 tests/CreateEndElementTests.phpnu [ PK eqYDf: ; tests/GetXmlDeclarationTests.phpnu [ PK eqYT T ? tests/CreateCommentTests.phpnu [ PK eqYG A tests/Bug21177Tests.phpnu [ PK eqYYq E tests/Bug21184Tests.phpnu [ PK eqY|\5 H tests/CollapseEmptyTagsTests.phpnu [ PK eqYG G ! QY tests/SplitQualifiedNameTests.phpnu [ PK eqYzt \ tests/ReverseEntitiesTests.phpnu [ PK eqYܬ$ $
n tests/GetDocTypeDeclarationTests.phpnu [ PK eqY۩ Tu tests/Bug18343Tests.phpnu [ PK eqY>M i| tests/Bug4950Tests.phpnu [ PK eqYrv tests/RaiseErrorTests.phpnu [ PK eqYC tests/ReplaceEntitiesTests.phpnu [ PK eqY4ej j ! tests/CreateCDataSectionTests.phpnu [ PK eqYe>4 4 ! { tests/CreateTagFromArrayTests.phpnu [ PK eqYYR" " ! tests/CreateStartElementTests.phpnu [ PK eqY! tests/AbstractUnitTests.phpnu [ PK eqYm4* * tests/CreateTagTests.phpnu [ PK eqYGs X tests/Bug5392Tests.phpnu [ PK eqYZt ! tests/AttributesToStringTests.phpnu [ PK eqYݑh " tests/IsValidNameTests.phpnu [ PK
*