PHP Class PHPUnit_Util_XML, qcodo

Author: Sebastian Bergmann ([email protected])
Mostrar archivo Open project: qcodo/qcodo Class Usage Examples

Public Methods

Method Description
assertValidKeys ( array $hash, array $validKeys ) : array Validate list of keys in the associative array.
convertSelectToTag ( string $selector, mixed $content = TRUE ) : array Parse a CSS selector into an associative array suitable for use with findNodes().
cssSelect ( array $selector, string $content, mixed $actual, boolean $isHtml = TRUE ) : false | array Parse an $actual document and return an array of DOMNodes matching the CSS $selector. If an error occurs, it will return FALSE.
findNodes ( DOMDocument $dom, array $options, boolean $isHtml = TRUE ) : array Parse out the options from the tag using DOM object tree.
load ( string | DOMDocument $actual, boolean $isHtml = FALSE, string $filename = '' ) : DOMDocument Load an $actual document into a DOMDocument. This is called from the selector assertions.
loadFile ( string $filename, boolean $isHtml = FALSE ) : DOMDocument Loads an XML (or HTML) file into a DOMDocument object.
nodeToText ( DOMNode $node ) : string
prepareString ( string $string ) : string
removeCharacterDataNodes ( DOMNode $node )
xmlToVariable ( DOMElement $element ) : mixed "Convert" a DOMElement object into a PHP variable.

Protected Methods

Method Description
convertToUtf8 ( string $string ) : string Converts a string to UTF-8 encoding.
getDescendants ( DOMNode $node ) : array Recursively get flat array of all descendants of this node.
getElementsByCaseInsensitiveTagName ( DOMDocument $dom, string $tag ) : DOMNodeList Gets elements by case insensitive tagname.
getNodeText ( DOMNode $node ) : string Get the text value of this node's child text node.
isUtf8 ( string $string ) : boolean Checks a string for UTF-8 encoding.

Method Details

assertValidKeys() public static method

Validate list of keys in the associative array.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
public static assertValidKeys ( array $hash, array $validKeys ) : array
$hash array
$validKeys array
return array

convertSelectToTag() public static method

Parse a CSS selector into an associative array suitable for use with findNodes().
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
public static convertSelectToTag ( string $selector, mixed $content = TRUE ) : array
$selector string
$content mixed
return array

convertToUtf8() protected static method

Converts a string to UTF-8 encoding.
protected static convertToUtf8 ( string $string ) : string
$string string
return string

cssSelect() public static method

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.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Tobias Schlitt ([email protected])
public static cssSelect ( array $selector, string $content, mixed $actual, boolean $isHtml = TRUE ) : false | array
$selector array
$content string
$actual mixed
$isHtml boolean
return false | array

findNodes() public static method

Parse out the options from the tag using DOM object tree.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Tobias Schlitt ([email protected])
public static findNodes ( DOMDocument $dom, array $options, boolean $isHtml = TRUE ) : array
$dom DOMDocument
$options array
$isHtml boolean
return array

getDescendants() protected static method

Recursively get flat array of all descendants of this node.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
protected static getDescendants ( DOMNode $node ) : array
$node DOMNode
return array

getElementsByCaseInsensitiveTagName() protected static method

Gets elements by case insensitive tagname.
protected static getElementsByCaseInsensitiveTagName ( DOMDocument $dom, string $tag ) : DOMNodeList
$dom DOMDocument
$tag string
return DOMNodeList

getNodeText() protected static method

Get the text value of this node's child text node.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
protected static getNodeText ( DOMNode $node ) : string
$node DOMNode
return string

isUtf8() protected static method

Checks a string for UTF-8 encoding.
protected static isUtf8 ( string $string ) : boolean
$string string
return boolean

load() public static method

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. 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.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
public static load ( string | DOMDocument $actual, boolean $isHtml = FALSE, string $filename = '' ) : DOMDocument
$actual string | DOMDocument
$isHtml boolean
$filename string
return DOMDocument

loadFile() public static method

Loads an XML (or HTML) file into a DOMDocument object.
public static loadFile ( string $filename, boolean $isHtml = FALSE ) : DOMDocument
$filename string
$isHtml boolean
return DOMDocument

nodeToText() public static method

public static nodeToText ( DOMNode $node ) : string
$node DOMNode
return string

prepareString() public static method

Author: Kore Nordmann ([email protected])
public static prepareString ( string $string ) : string
$string string
return string

removeCharacterDataNodes() public static method

Author: Mattis Stordalen Flister ([email protected])
public static removeCharacterDataNodes ( DOMNode $node )
$node DOMNode

xmlToVariable() public static method

"Convert" a DOMElement object into a PHP variable.
public static xmlToVariable ( DOMElement $element ) : mixed
$element DOMElement
return mixed