Author: kn
Date: Wed Feb 6 17:58:38 2008
New Revision: 7317
Log:
- Readded tests for xhtml to docbook conversion
Added:
experimental/Document/tests/converter_xhtml_docbook_test.php (with props)
Modified:
experimental/Document/src/converters/xslt.php
experimental/Document/src/converters/xslt/ezp3_ezp4.php
experimental/Document/src/converters/xslt/xhtml_docbook.php
experimental/Document/tests/converter_ezp3_ezp4_test.php
experimental/Document/tests/suite.php
Modified: experimental/Document/src/converters/xslt.php
==============================================================================
--- experimental/Document/src/converters/xslt.php [iso-8859-1] (original)
+++ experimental/Document/src/converters/xslt.php [iso-8859-1] Wed Feb 6
17:58:38 2008
@@ -80,12 +80,7 @@
}
// Transform input document
- $document = $this->xsltProcessor->transformToDoc(
$doc->getDomDocument() );
-
- // Create destination document from DOMDocument
- $dest = new ezcDocumentEzp4Xml();
- $dest->load( $document );
- return $dest;
+ return $this->xsltProcessor->transformToDoc( $doc->getDomDocument() );
}
}
Modified: experimental/Document/src/converters/xslt/ezp3_ezp4.php
==============================================================================
--- experimental/Document/src/converters/xslt/ezp3_ezp4.php [iso-8859-1]
(original)
+++ experimental/Document/src/converters/xslt/ezp3_ezp4.php [iso-8859-1] Wed
Feb 6 17:58:38 2008
@@ -87,56 +87,6 @@
return substr( $tagList, 0, -4 );
}
-
- /***
- * Old implementation, maybe possible to reuse some parts later. Since we
- * got no tests yet, leave it commented out.
- *
-
- public function __construct( $parameters = array() )
- {
- $this->parameters = $parameters;
-
- if ( isset( $this->parameters['inline_custom_tags'] ) )
- foreach( $this->parameters['inline_custom_tags'] as $key=>$tagname )
- {
- self::$inlineCustomTags .= "@name = '$tagname'";
- if ( $key != count( $parameters['inline_custom_tags'] ) - 1 )
- self::$inlineCustomTags .= ' or ';
- }
- }
-
- /**
- * Returns converted document
- *
- * @return ezcDocumentXML
- * /
- static public function convert( ezcDocument $doc, $parameters = array() )
- {
- if ( !self::$proc )
- {
- if ( !self::$xslt )
- {
- self::$xslt = new DOMDocument;
- self::$xslt->load( dirname( __FILE__ ) .
'/../converters/ezp3_ezp4.xsl' );
- }
- self::$proc = new XSLTProcessor;
- self::$proc->importStyleSheet( self::$xslt );
- self::$proc->registerPHPFunctions();
- }
-
- // XSLT transformation
- $resultDOM = self::$proc->transformToDoc( $doc->getDOM() );
-
- $resultDoc = new ezcDocumentXML( 'ezp4', $resultDOM);
- return $resultDoc;
- }
-
- static public function getInlineCustomTags()
- {
- return self::$inlineCustomTags;
- }
- // */
}
?>
Modified: experimental/Document/src/converters/xslt/xhtml_docbook.php
==============================================================================
--- experimental/Document/src/converters/xslt/xhtml_docbook.php [iso-8859-1]
(original)
+++ experimental/Document/src/converters/xslt/xhtml_docbook.php [iso-8859-1]
Wed Feb 6 17:58:38 2008
@@ -29,41 +29,23 @@
parent::__construct( dirname( __FILE__ ) . '/xhtml_docbook.xsl' );
}
- /***
- * Old implementation, maybe possible to reuse some parts later. Since we
- * got no tests yet, leave it commented out.
+ /**
+ * Convert documents between two formats
+ *
+ * Convert documents of the given type to the requested type.
*
+ * @param ezcDocumentXmlBase $doc
+ * @return ezcDocumentXmlBase
+ */
+ public function convert( $doc )
+ {
+ $document = parent::convert( $doc );
- public function __construct( $parameters = array() )
- {
- $this->parameters = $parameters;
+ // Create destination document from DOMDocument
+ $dest = new ezcDocumentDocbook();
+ $dest->loadDomDocument( $document );
+ return $dest;
}
-
- /**
- * Returns converted document
- *
- * @return ezcDocumentXML
- * /
- static public function convert( ezcDocument $doc, $parameters = array() )
- {
- if ( !self::$proc )
- {
- if ( !self::$xslt )
- {
- self::$xslt = new DOMDocument;
- self::$xslt->load( dirname( __FILE__ ) .
'/../converters/xhtml_docbook.xsl' );
- }
- self::$proc = new XSLTProcessor;
- self::$proc->importStyleSheet( self::$xslt );
- }
-
- // XSLT transformation
- $resultDOM = self::$proc->transformToDoc( $doc->getDOM() );
-
- $resultDoc = new ezcDocumentXML( 'docbook', $resultDOM);
- return $resultDoc;
- }
- // */
}
?>
Modified: experimental/Document/tests/converter_ezp3_ezp4_test.php
==============================================================================
--- experimental/Document/tests/converter_ezp3_ezp4_test.php [iso-8859-1]
(original)
+++ experimental/Document/tests/converter_ezp3_ezp4_test.php [iso-8859-1] Wed
Feb 6 17:58:38 2008
@@ -15,7 +15,7 @@
* @package Document
* @subpackage Tests
*/
-class ezcDocumentConverterEzp3TpEzp4Tests extends ezcTestCase
+class ezcDocumentConverterEzp3ToEzp4Tests extends ezcTestCase
{
public static function suite()
{
Added: experimental/Document/tests/converter_xhtml_docbook_test.php
==============================================================================
--- experimental/Document/tests/converter_xhtml_docbook_test.php (added)
+++ experimental/Document/tests/converter_xhtml_docbook_test.php [iso-8859-1]
Wed Feb 6 17:58:38 2008
@@ -1,0 +1,73 @@
+<?php
+/**
+ * ezcDocumentConverterEzp3TpEzp4Tests
+ *
+ * @package Document
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Test suite for class.
+ *
+ * @package Document
+ * @subpackage Tests
+ */
+class ezcDocumentConverterXhtmlToDocbookTests extends ezcTestCase
+{
+ public static function suite()
+ {
+ return new PHPUnit_Framework_TestSuite( __CLASS__ );
+ }
+
+ public static function getTestDocuments()
+ {
+ return array(
+ array(
+ dirname( __FILE__ ) . '/files/xhtml_sample_basic.xml',
+ dirname( __FILE__ ) . '/files/docbook_sample_basic.xml',
+ ),
+ array(
+ dirname( __FILE__ ) . '/files/xhtml_sample_lists.xml',
+ dirname( __FILE__ ) . '/files/docbook_sample_lists.xml',
+ ),
+ array(
+ dirname( __FILE__ ) . '/files/xhtml_sample_tables.xml',
+ dirname( __FILE__ ) . '/files/docbook_sample_tables.xml',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider getTestDocuments
+ */
+ public function testLoadXmlDocumentFromFile( $from, $to )
+ {
+ if ( !ezcBaseFeatures::hasExtensionSupport( 'xsl' ) )
+ {
+ $this->markTestSkipped( 'You need XSLT support for this test.' );
+ }
+
+ $doc = new ezcDocumentXhtml();
+ $doc->loadFile( $from );
+
+ $converter = new ezcDocumentXhtmlToDocbookConverter();
+ $created = $converter->convert( $doc );
+
+ $this->assertTrue(
+ $created instanceof ezcDocumentDocbook
+ );
+
+ $dest = new DOMDocument();
+ $dest->load( $to );
+
+ $this->assertEquals(
+ $dest,
+ $created->getDomDocument()
+ );
+ }
+}
+
+?>
Propchange: experimental/Document/tests/converter_xhtml_docbook_test.php
------------------------------------------------------------------------------
svn:eol-style = native
Modified: experimental/Document/tests/suite.php
==============================================================================
--- experimental/Document/tests/suite.php [iso-8859-1] (original)
+++ experimental/Document/tests/suite.php [iso-8859-1] Wed Feb 6 17:58:38 2008
@@ -20,6 +20,7 @@
require_once 'document_options_xml_base_test.php';
require_once 'document_xml_base_test.php';
require_once 'converter_ezp3_ezp4_test.php';
+require_once 'converter_xhtml_docbook_test.php';
class ezcDocumentSuite extends PHPUnit_Framework_TestSuite
@@ -34,12 +35,11 @@
parent::__construct();
$this->setName( "Document" );
-// $this->addTest( ezcDocumentConvertXhtmlTest::suite() );
-
$this->addTest( ezcDocumentOptionsXmlBaseTests::suite() );
$this->addTest( ezcDocumentXmlBaseTests::suite() );
- $this->addTest( ezcDocumentConverterEzp3TpEzp4Tests::suite() );
+ $this->addTest( ezcDocumentConverterEzp3ToEzp4Tests::suite() );
+ $this->addTest( ezcDocumentConverterXhtmlToDocbookTests::suite() );
}
}
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components