Documentation

PHPUnit_Util_XML
in package

XML helpers.

Tags
since

Class available since Release 3.2.0

Table of Contents

assertValidKeys()  : array<string|int, mixed>
Validate list of keys in the associative array.
convertSelectToTag()  : array<string|int, mixed>
Parse a CSS selector into an associative array suitable for use with findNodes().
cssSelect()  : bool|array<string|int, mixed>
Parse an $actual document and return an array of DOMNodes matching the CSS $selector. If an error occurs, it will return false.
findNodes()  : array<string|int, mixed>
Parse out the options from the tag using DOM object tree.
load()  : DOMDocument
Load an $actual document into a DOMDocument. This is called from the selector assertions.
loadFile()  : DOMDocument
Loads an XML (or HTML) file into a DOMDocument object.
nodeToText()  : string
prepareString()  : string
Escapes a string for the use in XML documents Any Unicode character is allowed, excluding the surrogate blocks, FFFE, and FFFF (not even as character reference).
removeCharacterDataNodes()  : mixed
xmlToVariable()  : mixed
"Convert" a DOMElement object into a PHP variable.
getDescendants()  : array<string|int, mixed>
Recursively get flat array of all descendants of this node.
getElementsByCaseInsensitiveTagName()  : DOMNodeList
Gets elements by case insensitive tagname.
getNodeText()  : string
Get the text value of this node's child text node.

Methods

assertValidKeys()

Validate list of keys in the associative array.

public static assertValidKeys(array<string|int, mixed> $hash, array<string|int, mixed> $validKeys) : array<string|int, mixed>
Parameters
$hash : array<string|int, mixed>
$validKeys : array<string|int, mixed>
Tags
throws
PHPUnit_Framework_Exception
since

Method available since Release 3.3.0

Return values
array<string|int, mixed>

convertSelectToTag()

Parse a CSS selector into an associative array suitable for use with findNodes().

public static convertSelectToTag(string $selector[, mixed $content = true ]) : array<string|int, mixed>
Parameters
$selector : string
$content : mixed = true
Tags
since

Method available since Release 3.3.0

Return values
array<string|int, mixed>

cssSelect()

Parse an $actual document and return an array of DOMNodes matching the CSS $selector. If an error occurs, it will return false.

public static cssSelect(array<string|int, mixed> $selector, string $content, mixed $actual[, bool $isHtml = true ]) : bool|array<string|int, mixed>

To only return nodes containing a certain content, give the $content to match as a string. Otherwise, setting $content to true will return all nodes matching $selector.

The $actual document may be a DOMDocument or a string containing XML or HTML, identified by $isHtml.

Parameters
$selector : array<string|int, mixed>
$content : string
$actual : mixed
$isHtml : bool = true
Tags
since

Method available since Release 3.3.0

Return values
bool|array<string|int, mixed>

findNodes()

Parse out the options from the tag using DOM object tree.

public static findNodes(DOMDocument $dom, array<string|int, mixed> $options[, bool $isHtml = true ]) : array<string|int, mixed>
Parameters
$dom : DOMDocument
$options : array<string|int, mixed>
$isHtml : bool = true
Tags
since

Method available since Release 3.3.0

Return values
array<string|int, mixed>

load()

Load an $actual document into a DOMDocument. This is called from the selector assertions.

public static load(string|DOMDocument $actual[, bool $isHtml = false ][, string $filename = '' ][, bool $xinclude = false ][, bool $strict = false ]) : DOMDocument

If $actual is already a DOMDocument, it is returned with no changes. Otherwise, $actual is loaded into a new DOMDocument as either HTML or XML, depending on the value of $isHtml. If $isHtml is false and $xinclude is true, xinclude is performed on the loaded DOMDocument.

Note: prior to PHPUnit 3.3.0, this method loaded a file and not a string as it currently does. To load a file into a DOMDocument, use loadFile() instead.

Parameters
$actual : string|DOMDocument
$isHtml : bool = false
$filename : string = ''
$xinclude : bool = false
$strict : bool = false
Tags
since

Method available since Release 3.3.0

Return values
DOMDocument

loadFile()

Loads an XML (or HTML) file into a DOMDocument object.

public static loadFile(string $filename[, bool $isHtml = false ][, bool $xinclude = false ][, bool $strict = false ]) : DOMDocument
Parameters
$filename : string
$isHtml : bool = false
$xinclude : bool = false
$strict : bool = false
Tags
since

Method available since Release 3.3.0

Return values
DOMDocument

nodeToText()

public static nodeToText(DOMNode $node) : string
Parameters
$node : DOMNode
Tags
since

Method available since Release 3.4.0

Return values
string

prepareString()

Escapes a string for the use in XML documents Any Unicode character is allowed, excluding the surrogate blocks, FFFE, and FFFF (not even as character reference).

public static prepareString(string $string) : string

See http://www.w3.org/TR/xml/#charsets

Parameters
$string : string
Tags
since

Method available since Release 3.4.6

Return values
string

removeCharacterDataNodes()

public static removeCharacterDataNodes(DOMNode $node) : mixed
Parameters
$node : DOMNode
Tags
since

Method available since Release 3.3.0

Return values
mixed

xmlToVariable()

"Convert" a DOMElement object into a PHP variable.

public static xmlToVariable(DOMElement $element) : mixed
Parameters
$element : DOMElement
Tags
since

Method available since Release 3.4.0

Return values
mixed

getDescendants()

Recursively get flat array of all descendants of this node.

protected static getDescendants(DOMNode $node) : array<string|int, mixed>
Parameters
$node : DOMNode
Tags
since

Method available since Release 3.3.0

Return values
array<string|int, mixed>

getElementsByCaseInsensitiveTagName()

Gets elements by case insensitive tagname.

protected static getElementsByCaseInsensitiveTagName(DOMDocument $dom, string $tag) : DOMNodeList
Parameters
$dom : DOMDocument
$tag : string
Tags
since

Method available since Release 3.4.0

Return values
DOMNodeList

getNodeText()

Get the text value of this node's child text node.

protected static getNodeText(DOMNode $node) : string
Parameters
$node : DOMNode
Tags
since

Method available since Release 3.3.0

Return values
string

Search results