protected function renderControl($options = [], $render = 'render') { ob_start(); $this->control->{$render}($options); $html = ob_get_clean(); return DomQuery::fromHtml($html); }
public function dom($response) { $html = $response->getSource(); libxml_use_internal_errors(true); $dom = DomQuery::fromHtml($html); libxml_clear_errors(); return $dom; }
/** * @param string $destination * @param array $params * @param array $post * * @return \Nette\Application\Responses\TextResponse * @throws \Exception */ protected function checkSitemap($destination, $params = [], $post = []) { /** @var \Nette\Application\Responses\TextResponse $response */ $response = $this->check($destination, $params, $post); if (!$this->__testbench_exception) { Assert::same(200, $this->getReturnCode()); Assert::type('Nette\\Application\\Responses\\TextResponse', $response); Assert::type('Nette\\Application\\UI\\ITemplate', $response->getSource()); $dom = @\Tester\DomQuery::fromHtml($response->getSource()); // @ - not valid HTML Assert::true($dom->has('urlset')); Assert::true($dom->has('url')); Assert::true($dom->has('loc')); } return $response; }
/** * @return DomQuery */ public static function getDomFromXml($xml) { $xml = strtr($xml, self::$HTML401NamedToNumeric); return DomQuery::fromXml($xml); }
protected function getDomQueryFromOb(Button $button, $data = [], $xml = false) { $out = $this->getStringFromOb($button, $data); return $xml ? DomQuery::fromXml($out) : DomQuery::fromHtml($out); }
/** * @param string $destination fully qualified presenter name (module:module:presenter) * @param array $params provided to the presenter usually via URL * @param array $post provided to the presenter via POST * * @return \Nette\Application\Responses\TextResponse * @throws \Exception */ protected function checkSitemap($destination, $params = [], $post = []) { /** @var \Nette\Application\Responses\TextResponse $response */ $response = $this->check($destination, $params, $post); if (!$this->__testbench_exception) { Assert::same(200, $this->getReturnCode()); Assert::type('Nette\\Application\\Responses\\TextResponse', $response); Assert::type('Nette\\Application\\UI\\ITemplate', $response->getSource()); $xml = \Tester\DomQuery::fromXml($response->getSource()); Assert::same('urlset', $xml->getName(), 'root element is'); $url = $xml->children(); Assert::same('url', $url->getName(), "child of 'urlset'"); Assert::same('loc', $url->children()->getName(), "child of 'url'"); } return $response; }