/** * @dataProvider getTestDocuments */ public function testCommonConversions($from, $to) { if (!is_file($to)) { $this->markTestSkipped("Comparision file '{$to}' not yet defined."); } $document = new ezcDocumentXhtml(); $document->setFilters(array(new ezcDocumentXhtmlElementFilter(), new ezcDocumentXhtmlMetadataFilter(), new ezcDocumentXhtmlTablesFilter())); $document->loadFile($from); $docbook = $document->getAsDocbook(); $xml = $docbook->save(); // Store test file, to have something to compare on failure $tempDir = $this->createTempDir('xhtml_tests_') . '/'; file_put_contents($tempDir . basename($to), $xml); $this->assertTrue($docbook->validateString($xml)); $this->assertEquals(file_get_contents($to), $xml, 'Document not visited as expected.'); // Remove tempdir, when nothing failed. $this->removeTempDir(); }
<?php require 'tutorial_autoload.php'; $xhtml = new ezcDocumentXhtml(); $xhtml->setFilters(array(new ezcDocumentXhtmlElementFilter(), new ezcDocumentXhtmlMetadataFilter(), new ezcDocumentXhtmlXpathFilter('//div[@class="document"]'))); $xhtml->loadFile('ez_components_introduction.html'); $docbook = $xhtml->getAsDocbook(); echo $docbook->save();