You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

247 lines
6.2 KiB

  1. <?php
  2. namespace dokuwiki\plugin\wrap\test;
  3. use DokuWikiTest;
  4. /**
  5. * Tests to ensure wrap syntax is correctly processed
  6. *
  7. * @group plugin_wrap
  8. * @group plugins
  9. */
  10. class SyntaxTest extends DokuWikiTest {
  11. protected $pluginsEnabled = ['wrap'];
  12. public function testNestedHeading() {
  13. $instructions = p_get_instructions("<WRAP>\n==== Heading ====\n\nSome text\n</WRAP>");
  14. $expected =
  15. [
  16. [
  17. 'document_start',
  18. [],
  19. 0
  20. ],
  21. [
  22. 'plugin',
  23. [
  24. 'wrap_divwrap',
  25. [
  26. DOKU_LEXER_ENTER,
  27. '<wrap'
  28. ],
  29. DOKU_LEXER_ENTER,
  30. '<WRAP>'
  31. ],
  32. 1
  33. ],
  34. [
  35. 'header',
  36. [
  37. 'Heading',
  38. 3,
  39. 8
  40. ],
  41. 8
  42. ],
  43. [
  44. 'plugin',
  45. [
  46. 'wrap_closesection',
  47. [],
  48. DOKU_LEXER_SPECIAL,
  49. false
  50. ],
  51. 8
  52. ],
  53. [
  54. 'p_open',
  55. [],
  56. 8
  57. ],
  58. [
  59. 'cdata',
  60. [
  61. 'Some text'
  62. ],
  63. 27
  64. ],
  65. [
  66. 'p_close',
  67. [],
  68. 37
  69. ],
  70. [
  71. 'plugin',
  72. [
  73. 'wrap_divwrap',
  74. [
  75. DOKU_LEXER_EXIT,
  76. ''
  77. ],
  78. DOKU_LEXER_EXIT,
  79. '</WRAP>'
  80. ],
  81. 37
  82. ],
  83. [
  84. 'document_end',
  85. [],
  86. 37
  87. ]
  88. ];
  89. $this->assertEquals($expected, $instructions);
  90. }
  91. public function testBlockNesting() {
  92. $instructions = p_get_instructions("<WRAP>\nFoo\n\n</div> </block> Bar\n</WRAP>");
  93. $expected =
  94. [
  95. [
  96. 'document_start',
  97. [],
  98. 0
  99. ],
  100. [
  101. 'plugin',
  102. [
  103. 'wrap_divwrap',
  104. [
  105. DOKU_LEXER_ENTER,
  106. '<wrap'
  107. ],
  108. DOKU_LEXER_ENTER,
  109. '<WRAP>'
  110. ],
  111. 1
  112. ],
  113. [
  114. 'p_open',
  115. [
  116. ],
  117. 1
  118. ],
  119. [
  120. 'cdata',
  121. [
  122. 'Foo'
  123. ],
  124. 8
  125. ],
  126. [
  127. 'p_close',
  128. [],
  129. 11
  130. ],
  131. [
  132. 'p_open',
  133. [
  134. ],
  135. 11
  136. ],
  137. [
  138. 'cdata',
  139. [
  140. '</div> </block> Bar'
  141. ],
  142. 13
  143. ],
  144. [
  145. 'p_close',
  146. [],
  147. 33
  148. ],
  149. [
  150. 'plugin',
  151. [
  152. 'wrap_divwrap',
  153. [
  154. DOKU_LEXER_EXIT,
  155. ''
  156. ],
  157. DOKU_LEXER_EXIT,
  158. '</WRAP>'
  159. ],
  160. 33
  161. ],
  162. [
  163. 'document_end',
  164. [],
  165. 33
  166. ]
  167. ];
  168. $this->assertEquals($expected, $instructions);
  169. }
  170. public function testInlineNesting() {
  171. $instructions = p_get_instructions("<wrap>Foo </span> </inline> Bar</wrap>");
  172. $expected =
  173. [
  174. [
  175. 'document_start',
  176. [],
  177. 0
  178. ],
  179. [
  180. 'p_open',
  181. [
  182. ],
  183. 0
  184. ],
  185. [
  186. 'plugin',
  187. [
  188. 'wrap_spanwrap',
  189. [
  190. DOKU_LEXER_ENTER,
  191. '<wrap'
  192. ],
  193. DOKU_LEXER_ENTER,
  194. '<wrap>'
  195. ],
  196. 1
  197. ],
  198. [
  199. 'cdata',
  200. [
  201. 'Foo </span> </inline> Bar'
  202. ],
  203. 7
  204. ],
  205. [
  206. 'plugin',
  207. [
  208. 'wrap_spanwrap',
  209. [
  210. DOKU_LEXER_EXIT,
  211. ''
  212. ],
  213. DOKU_LEXER_EXIT,
  214. '</wrap>'
  215. ],
  216. 32
  217. ],
  218. [
  219. 'cdata',
  220. [
  221. ''
  222. ],
  223. 39
  224. ],
  225. [
  226. 'p_close',
  227. [],
  228. 39
  229. ],
  230. [
  231. 'document_end',
  232. [],
  233. 39
  234. ]
  235. ];
  236. $this->assertEquals($expected, $instructions);
  237. }
  238. }