本文整理汇总了PHP中PHPUnit_Util_XML::removeCharacterDataNodes方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_XML::removeCharacterDataNodes方法的具体用法?PHP PHPUnit_Util_XML::removeCharacterDataNodes怎么用?PHP PHPUnit_Util_XML::removeCharacterDataNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_XML
的用法示例。
在下文中一共展示了PHPUnit_Util_XML::removeCharacterDataNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertEqualXMLStructure
/**
* Asserts that a hierarchy of DOMElements matches.
*
* @param DOMElement $expectedElement
* @param DOMElement $actualElement
* @param bool $checkAttributes
* @param string $message
* @author Mattis Stordalen Flister <mattis@xait.no>
* @since Method available since Release 3.3.0
*/
public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '')
{
$expectedElement = clone $expectedElement;
$actualElement = clone $actualElement;
self::assertEquals($expectedElement->tagName, $actualElement->tagName, $message);
if ($checkAttributes) {
self::assertEquals($expectedElement->attributes->length, $actualElement->attributes->length, sprintf('%s%sNumber of attributes on node "%s" does not match', $message, !empty($message) ? "\n" : '', $expectedElement->tagName));
for ($i = 0; $i < $expectedElement->attributes->length; $i++) {
$expectedAttribute = $expectedElement->attributes->item($i);
$actualAttribute = $actualElement->attributes->getNamedItem($expectedAttribute->name);
if (!$actualAttribute) {
self::fail(sprintf('%s%sCould not find attribute "%s" on node "%s"', $message, !empty($message) ? "\n" : '', $expectedAttribute->name, $expectedElement->tagName));
}
}
}
PHPUnit_Util_XML::removeCharacterDataNodes($expectedElement);
PHPUnit_Util_XML::removeCharacterDataNodes($actualElement);
self::assertEquals($expectedElement->childNodes->length, $actualElement->childNodes->length, sprintf('%s%sNumber of child nodes of "%s" differs', $message, !empty($message) ? "\n" : '', $expectedElement->tagName));
for ($i = 0; $i < $expectedElement->childNodes->length; $i++) {
self::assertEqualXMLStructure($expectedElement->childNodes->item($i), $actualElement->childNodes->item($i), $checkAttributes, $message);
}
}