findNodes() public static method

Parse out the options from the tag using DOM object tree.
Author: Mike Naberezny (mike@maintainable.com)
Author: Derek DeVries (derek@maintainable.com)
Author: Tobias Schlitt (toby@php.net)
public static findNodes ( DOMDocument $dom, array $options, boolean $isHtml = TRUE ) : array
$dom DOMDocument
$options array
$isHtml boolean
return array
Example #1
0
 /**
  * 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);
 }
Example #2
0
 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;
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * @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;
 }
Example #5
0
 /**
  * @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;
 }