123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- class ezcDocumentConverterDocbookToEzXmlTests extends ezcTestCase
- {
- protected static $testDocuments = null;
- public static function suite()
- {
- return new PHPUnit_Framework_TestSuite( __CLASS__ );
- }
- public function testEzXmlConverterOptionsUnknownOption()
- {
- $options = new ezcDocumentDocbookToEzXmlConverterOptions();
- try
- {
- $options->notExistingOption = 0;
- $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
- }
- catch ( ezcBasePropertyNotFoundException $e )
- { }
- }
- public static function getTestDocuments()
- {
- if ( self::$testDocuments === null )
- {
-
- $testFiles = glob( dirname( __FILE__ ) . '/files/docbook/ezxml/s_*.xml' );
-
- foreach ( $testFiles as $file )
- {
- self::$testDocuments[] = array(
- $file,
- substr( $file, 0, -3 ) . 'ezp'
- );
- }
- }
- return self::$testDocuments;
- return array_slice( self::$testDocuments, 0, 3 );
- }
-
- public function testLoadXmlDocumentFromFile( $from, $to )
- {
- if ( !is_file( $to ) )
- {
- $this->markTestSkipped( "Comparision file '$to' not yet defined." );
- }
- $doc = new ezcDocumentDocbook();
- $doc->loadFile( $from );
- $converter = new ezcDocumentDocbookToEzXmlConverter();
- $created = $converter->convert( $doc );
- $this->assertTrue(
- $created instanceof ezcDocumentEzXml,
- 'Not of expected document type ezcDocumentEzXml,'
- );
-
- $tempDir = $this->createTempDir( 'docbook_ezxml_custom_' ) . '/';
- file_put_contents( $tempDir . basename( $to ), $xml = $created->save() );
- $this->assertTrue(
- ( $errors = $created->validateString( $xml ) ) === true,
- ( is_array( $errors ) ? implode( PHP_EOL, $errors ) : 'Expected true' )
- );
- $this->assertEquals(
- file_get_contents( $to ),
- $xml
- );
-
- $this->removeTempDir();
- }
- }
- ?>
|