コード例 #1
0
ファイル: TestCase.php プロジェクト: kollarovic/navigation
 protected function renderControl($options = [], $render = 'render')
 {
     ob_start();
     $this->control->{$render}($options);
     $html = ob_get_clean();
     return DomQuery::fromHtml($html);
 }
コード例 #2
0
ファイル: PresenterTestCase.php プロジェクト: b4nan/utils
 public function dom($response)
 {
     $html = $response->getSource();
     libxml_use_internal_errors(true);
     $dom = DomQuery::fromHtml($html);
     libxml_clear_errors();
     return $dom;
 }
コード例 #3
0
ファイル: TPresenter.php プロジェクト: jakubskrz/testbench
 /**
  * @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;
 }
コード例 #4
0
ファイル: DomHelper.php プロジェクト: venne/tester
 /**
  * @return DomQuery
  */
 public static function getDomFromXml($xml)
 {
     $xml = strtr($xml, self::$HTML401NamedToNumeric);
     return DomQuery::fromXml($xml);
 }
コード例 #5
0
ファイル: BaseTestCase.php プロジェクト: mesour/button
 protected function getDomQueryFromOb(Button $button, $data = [], $xml = false)
 {
     $out = $this->getStringFromOb($button, $data);
     return $xml ? DomQuery::fromXml($out) : DomQuery::fromHtml($out);
 }
コード例 #6
0
ファイル: TPresenter.php プロジェクト: mrtnzlml/testbench
 /**
  * @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;
 }