Exemple #1
0
 protected function renderControl($options = [], $render = 'render')
 {
     ob_start();
     $this->control->{$render}($options);
     $html = ob_get_clean();
     return DomQuery::fromHtml($html);
 }
Exemple #2
0
 public function dom($response)
 {
     $html = $response->getSource();
     libxml_use_internal_errors(true);
     $dom = DomQuery::fromHtml($html);
     libxml_clear_errors();
     return $dom;
 }
Exemple #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;
 }
Exemple #4
0
 protected function getDomQueryFromOb(Button $button, $data = [], $xml = false)
 {
     $out = $this->getStringFromOb($button, $data);
     return $xml ? DomQuery::fromXml($out) : DomQuery::fromHtml($out);
 }
Exemple #5
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 checkAction($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());
         $html = (string) $response->getSource();
         //DOMDocument doesn't handle HTML tags inside of script tags very well
         $html = preg_replace('~<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>~', '', $html);
         //http://stackoverflow.com/a/6660315/3135248
         $dom = @\Tester\DomQuery::fromHtml($html);
         Assert::true($dom->has('html'), "missing 'html' tag");
         Assert::true($dom->has('title'), "missing 'title' tag");
         Assert::true($dom->has('body'), "missing 'body' tag");
     }
     return $response;
 }