/** * @param CM_Dom_NodeList $page * @param bool $warnings */ public static function assertTidy(CM_Dom_NodeList $page, $warnings = true) { if (!extension_loaded('tidy')) { self::markTestSkipped('The tidy extension is not available.'); } $html = $page->getHtml(); $tidy = new tidy(); $tidyConfig = array('show-errors' => 1, 'show-warnings' => $warnings); $tidy->parseString($html, $tidyConfig, 'UTF8'); //$tidy->cleanRepair(); $tidy->diagnose(); $lines = array_reverse(explode("\n", $tidy->errorBuffer)); $content = ''; foreach ($lines as $line) { if (empty($line) || $line == 'No warnings or errors were found.' || strpos($line, 'Info:') === 0 || strpos($line, 'errors were found!') > 0 || strpos($line, 'proprietary attribute') != false) { // ignore } else { $content .= $line . PHP_EOL; } } self::assertEmpty($content, $content); }
public function testRenderWithoutNamespace() { $html = new CM_Dom_NodeList(smarty_function_component(array('name' => '*_Component_Notfound'), $this->_template)); $this->assertContains('class="CM_Component_Notfound', $html->getHtml()); }
public function testGetHtmlJavascriptTemplate() { $list = new CM_Dom_NodeList('<script type="text/template"><div class="clclcl">TestText</div></script><span class="pr">Left</span>'); $this->assertSame('<span class="pr">Left</span>', $list->getHtml()); }
public function testGetHtmlWeirdDocument() { $list = new CM_Dom_NodeList('<!-- comment --><html><!-- comment --><body><p>hello</p></body><!-- comment --></html><!-- comment -->'); $this->assertSame('<p>hello</p>', $list->getHtml()); }