document_wiki_test.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * ezcDocumentConverterEzp3TpEzp4Tests
  4. *
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. * @package Document
  23. * @version //autogen//
  24. * @subpackage Tests
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  26. */
  27. /**
  28. * Test suite for class.
  29. *
  30. * @package Document
  31. * @subpackage Tests
  32. */
  33. class ezcDocumentWikiTests extends ezcTestCase
  34. {
  35. public static function suite()
  36. {
  37. return new PHPUnit_Framework_TestSuite( __CLASS__ );
  38. }
  39. public function testReadCreoleDocument()
  40. {
  41. $wiki = new ezcDocumentCreoleWiki();
  42. $wiki->loadFile( dirname( __FILE__ ) . '/files/wiki/creole/s_008_paragraphs.txt' );
  43. $docbook = $wiki->getAsDocbook();
  44. $this->assertEquals(
  45. file_get_contents( dirname( __FILE__ ) . '/files/wiki/creole/s_008_paragraphs.xml' ),
  46. $docbook->save(),
  47. 'Document not visited as expected.'
  48. );
  49. }
  50. public function testWriteCreoleDocument()
  51. {
  52. $docbook = new ezcDocumentDocbook();
  53. $docbook->loadFile( dirname( __FILE__ ) . '/files/wiki/creole/s_008_paragraphs.xml' );
  54. $wiki = new ezcDocumentCreoleWiki();
  55. $wiki->createFromDocbook( $docbook );
  56. $this->assertEquals(
  57. file_get_contents( dirname( __FILE__ ) . '/files/wiki/creole/s_008_paragraphs.txt' ),
  58. $wiki->save(),
  59. 'Document not visited as expected.'
  60. );
  61. }
  62. public function testReadDokuwikiDocument()
  63. {
  64. $wiki = new ezcDocumentDokuwikiWiki();
  65. $wiki->loadFile( dirname( __FILE__ ) . '/files/wiki/dokuwiki/s_001_inline_markup.txt' );
  66. $docbook = $wiki->getAsDocbook();
  67. $this->assertEquals(
  68. file_get_contents( dirname( __FILE__ ) . '/files/wiki/dokuwiki/s_001_inline_markup.xml' ),
  69. $docbook->save(),
  70. 'Document not visited as expected.'
  71. );
  72. }
  73. public function testWriteDokuwikiDocument()
  74. {
  75. $docbook = new ezcDocumentDocbook();
  76. $docbook->loadFile( dirname( __FILE__ ) . '/files/wiki/dokuwiki/s_001_inline_markup.xml' );
  77. try
  78. {
  79. $wiki = new ezcDocumentDokuwikiWiki();
  80. $wiki->createFromDocbook( $docbook );
  81. $wiki->save();
  82. $this->fail( 'Expected ezcDocumentMissingVisitorException' );
  83. }
  84. catch ( ezcDocumentMissingVisitorException $e )
  85. { /* Expected */ }
  86. }
  87. public function testReadConfluenceDocument()
  88. {
  89. $wiki = new ezcDocumentConfluenceWiki();
  90. $wiki->loadFile( dirname( __FILE__ ) . '/files/wiki/confluence/s_002_inline_markup.txt' );
  91. $docbook = $wiki->getAsDocbook();
  92. $this->assertEquals(
  93. file_get_contents( dirname( __FILE__ ) . '/files/wiki/confluence/s_002_inline_markup.xml' ),
  94. $docbook->save(),
  95. 'Document not visited as expected.'
  96. );
  97. }
  98. public function testWriteConfluenceDocument()
  99. {
  100. $docbook = new ezcDocumentDocbook();
  101. $docbook->loadFile( dirname( __FILE__ ) . '/files/wiki/confluence/s_002_inline_markup.xml' );
  102. try
  103. {
  104. $wiki = new ezcDocumentConfluenceWiki();
  105. $wiki->createFromDocbook( $docbook );
  106. $wiki->save();
  107. $this->fail( 'Expected ezcDocumentMissingVisitorException' );
  108. }
  109. catch ( ezcDocumentMissingVisitorException $e )
  110. { /* Expected */ }
  111. }
  112. }
  113. ?>