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