Exemplo n.º 1
0
 protected function renderControl($options = [], $render = 'render')
 {
     ob_start();
     $this->control->{$render}($options);
     $html = ob_get_clean();
     return DomQuery::fromHtml($html);
 }
Exemplo n.º 2
0
 public function dom($response)
 {
     $html = $response->getSource();
     libxml_use_internal_errors(true);
     $dom = DomQuery::fromHtml($html);
     libxml_clear_errors();
     return $dom;
 }
Exemplo n.º 3
0
 /**
  * @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;
 }
Exemplo n.º 4
0
 /**
  * @return DomQuery
  */
 public static function getDomFromXml($xml)
 {
     $xml = strtr($xml, self::$HTML401NamedToNumeric);
     return DomQuery::fromXml($xml);
 }
Exemplo n.º 5
0
 protected function getDomQueryFromOb(Button $button, $data = [], $xml = false)
 {
     $out = $this->getStringFromOb($button, $data);
     return $xml ? DomQuery::fromXml($out) : DomQuery::fromHtml($out);
 }
Exemplo n.º 6
0
 /**
  * @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;
 }