markTestSkipped( "Comparision file '$to' not yet defined." ); } $doc = new ezcDocumentDocbook(); $doc->loadFile( $from ); $converter = new ezcDocumentDocbookToOdtConverter(); $converter->options->styler->addStylesheetFile( dirname( __FILE__ ) . '/odt/test_data/test_styles.pcss' ); $created = $converter->convert( $doc ); $this->assertTrue( $created instanceof ezcDocumentOdt ); // Store test file, to have something to compare on failure $tempDir = $this->createTempDir( 'docbook_odt_custom_' ) . '/'; $tempFile = $tempDir . basename( $to ); file_put_contents( $tempFile, ( $xml = $created->save() ) ); if ( self::WRITE_RESULTS ) { copy( $tempFile, $to ); } $this->assertTrue( ( $errors = $created->validateString( $xml ) ), ( is_array( $errors ) ? implode( PHP_EOL, $errors ) : 'Expected true' ) ); $this->assertEquals( file_get_contents( $to ), $xml ); // Remove tempdir, when nothing failed. $this->removeTempDir(); } /** * @dataProvider getTestDocuments */ public function testStylerCalls() { $testDocs = self::getTestDocuments(); if ( count( $testDocs ) < 1 ) { throw new RuntimeException( 'Missing test documents.' ); } $doc = new ezcDocumentDocbook(); $doc->loadFile( $testDocs[0][0] ); $stylerMock = new ezcDocumentOdtTestStyler(); $converter = new ezcDocumentDocbookToOdtConverter( new ezcDocumentDocbookToOdtConverterOptions( array( 'styler' => $stylerMock ) ) ); $created = $converter->convert( $doc ); $this->assertTrue( $stylerMock->odtDocument instanceof DOMDocument ); $this->assertEquals( 38, count( $stylerMock->seenElements ) ); } } ?>