|', $content);
unlink($tmpfname);
}
// This test reads a document into a dom, turn the dom into a document,
// then tries to read that document again. This makes sure we are reading,
// and generating a document that works at a high level.
public function testItWorks()
{
$dom = $this->html5->load(__DIR__ . '/Html5Test.html');
$this->assertInstanceOf('\DOMDocument', $dom);
$this->assertEmpty($this->html5->getErrors());
$saved = $this->html5->saveHTML($dom);
$dom2 = $this->html5->loadHTML($saved);
$this->assertInstanceOf('\DOMDocument', $dom2);
$this->assertEmpty($this->html5->getErrors());
}
public function testConfig()
{
$html5 = $this->getInstance();
$options = $html5->getOptions();
$this->assertEquals(false, $options['encode_entities']);
$html5 = $this->getInstance(array(
'foo' => 'bar',
'encode_entities' => true
));
$options = $html5->getOptions();
$this->assertEquals('bar', $options['foo']);
$this->assertEquals(true, $options['encode_entities']);
// Need to reset to original so future tests pass as expected.
// $this->getInstance()->setOption('encode_entities', false);
}
public function testSvg()
{
$dom = $this->html5->loadHTML(
'
foo bar baz
');
$this->assertEmpty($this->html5->getErrors());
// Test a mixed case attribute.
$list = $dom->getElementsByTagName('svg');
$this->assertNotEmpty($list->length);
$svg = $list->item(0);
$this->assertEquals("0 0 3 2", $svg->getAttribute('viewBox'));
$this->assertFalse($svg->hasAttribute('viewbox'));
// Test a mixed case tag.
// Note: getElementsByTagName is not case sensetitive.
$list = $dom->getElementsByTagName('textPath');
$this->assertNotEmpty($list->length);
$textPath = $list->item(0);
$this->assertEquals('textPath', $textPath->tagName);
$this->assertNotEquals('textpath', $textPath->tagName);
$html = $this->html5->saveHTML($dom);
$this->assertRegExp('|