loadFile(
dirname( __FILE__ ) . '/files/xhtml_sample_basic.xml'
);
$this->assertTrue(
$doc->getDomDocument() instanceof DOMDocument,
'DOMDocument not created properly'
);
}
public function testLoadXmlDocumentFromString()
{
$string = file_get_contents(
dirname( __FILE__ ) . '/files/xhtml_sample_basic.xml'
);
$doc = new ezcDocumentXhtml();
$doc->loadString( $string );
$this->assertTrue(
$doc->getDomDocument() instanceof DOMDocument,
'DOMDocument not created properly'
);
}
public function testLoadErrnousXmlDocument()
{
$doc = new ezcDocumentXhtml();
try
{
$doc->loadFile(
dirname( __FILE__ ) . '/files/xhtml_sample_errnous.xml'
);
}
catch ( ezcDocumentErrnousXmlException $e )
{
$errors = $e->getXmlErrors();
$this->assertSame(
2,
count( $errors ),
'Expected 2 XML errors.'
);
}
$this->assertTrue(
$doc->getDomDocument() instanceof DOMDocument,
'DOMDocument not created properly'
);
}
public function testLoadErrnousXmlDocumentSilent()
{
$doc = new ezcDocumentXhtml();
$doc->options->failOnError = false;
$doc->loadFile(
dirname( __FILE__ ) . '/files/xhtml_sample_errnous.xml'
);
$this->assertTrue(
$doc->getDomDocument() instanceof DOMDocument,
'DOMDocument not created properly'
);
}
public function testSerializeXml()
{
$doc = new ezcDocumentXhtml();
$doc->loadFile(
dirname( __FILE__ ) . '/files/xhtml_sample_basic.xml'
);
$this->assertEquals(
file_get_contents( dirname( __FILE__ ) . '/files/xhtml_sample_basic.xml' ),
$doc->save()
);
}
public function testSerializeXmlFormat()
{
$doc = new ezcDocumentXhtml();
$doc->options->indentXml = true;
$doc->loadFile(
dirname( __FILE__ ) . '/files/xhtml_sample_basic.xml'
);
$this->assertEquals(
file_get_contents( dirname( __FILE__ ) . '/files/xhtml_sample_basic_indented.xml' ),
$doc->save()
);
}
}
?>