public function testWhitewashingHeaders() { $parser = new PHPricot_Parser(); $doc = $parser->parse(file_get_contents(dirname(__FILE__) . "/_files/whitewashing.html")); $cssHandler = new PHPricot_CssParser_EventHandler($doc); $cssParser = new CssParser('div.box h2', $cssHandler); $cssParser->parse(); $headers = $cssHandler->getMatches(); $this->assertEquals(10, count($headers), "Whitewashing Main Page example should have 10 h2 tags"); }
public function __construct($input) { if (is_string($input)) { $parser = new PHPricot_Parser(); $doc = $parser->parse($input); } else { if ($input instanceof PHPricot_Document) { $doc = $input; } else { if ($input instanceof PHPricot_Nodes_Node) { $doc = new PHPricot_Document(); $doc->childNodes[] = $input; } else { if (is_array($input)) { $doc = new PHPricot_Document(); $doc->childNodes = $input; } else { throw new InvalidArgumentException('PHPricot_Query expects an HTML string as argument.'); } } } } $this->doc = $doc; }