/** * Note: we are overriding this method to remove the deprecated error * @see https://tracker.moodle.org/browse/MDL-47129 * * @param array $matcher * @param string $actual * @param string $message * @param boolean $ishtml * * @deprecated 3.0 */ public static function assertNotTag($matcher, $actual, $message = '', $ishtml = true) { $dom = PHPUnit_Util_XML::load($actual, $ishtml); $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $ishtml); $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; self::assertFalse($matched, $message); }
private function findElementContent($html, $matcher) { $el = \PHPUnit_Util_XML::findNodes(dom_import_simplexml(simplexml_load_string($html))->ownerDocument, $matcher); if ($el === false) { return false; } return $el[0]->textContent; }
/** * This assertion is the exact opposite of assertTag(). * * Rather than asserting that $matcher results in a match, it asserts that * $matcher does not match. * * @param array $matcher * @param string $actual * @param string $message * @param bool $isHtml * @since Method available since Release 3.3.0 * @author Mike Naberezny <*****@*****.**> * @author Derek DeVries <*****@*****.**> * @deprecated */ public static function assertNotTag($matcher, $actual, $message = '', $isHtml = true) { trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED); $dom = PHPUnit_Util_XML::load($actual, $isHtml); $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; self::assertFalse($matched, $message); }
/** * @param array $matcher * @param string $actual * @param bool $isHtml * * @return bool */ private static function tagMatch($matcher, $actual, $isHtml = true) { $dom = PHPUnit_Util_XML::load($actual, $isHtml); $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); return count($tags) > 0 && $tags[0] instanceof DOMNode; }
/** * @param array $options * @param DOMDocument $actual * @return boolean * @since Method available since Release 3.3.0 * @author Mike Naberezny <*****@*****.**> * @author Derek DeVries <*****@*****.**> */ protected static function doXmlTag(array $options, DOMDocument $actual) { $tags = PHPUnit_Util_XML::findNodes($actual, $options); return count($tags) > 0 && $tags[0] instanceof DOMNode; }