public static function assertXMLTag($matcher, $actualXml, $message = '')
{
// Provide default values.
$matcher += array('attributes' => array());
// Create an XPath query that selects the xml tag.
$query = '//' . $matcher['tag'];
// Append XPath selectors for the attributes and content text.
$selectors = array();
foreach ($matcher['attributes'] as $attribute => $value) {
$selectors[] = "@{$attribute}='{$value}'";
}
if (!empty($matcher['content'])) {
$selectors[] = "contains(.,'{$matcher['content']}')";
}
if (!empty($selectors)) {
$query .= '[' . implode(' and ', $selectors) . ']';
}
// Execute the query.
$document = new DOMDocument();
$document->loadXML($actualXml);
$xpath = new DOMXPath($document);
self::assertGreaterThanOrEqual(1, $xpath->query($query)->length, $message);
}