|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (c) 2016 Mark C. Prins <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* Permission to use, copy, modify, and distribute this software for any |
|
6
|
|
|
* purpose with or without fee is hereby granted, provided that the above |
|
7
|
|
|
* copyright notice and this permission notice appear in all copies. |
|
8
|
|
|
* |
|
9
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
10
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
11
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
12
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
13
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
14
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
15
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
16
|
|
|
*/ |
|
17
|
|
|
/** |
|
18
|
|
|
* Syntax tests for the yalist plugin. |
|
19
|
|
|
* |
|
20
|
|
|
* @group plugin_yalist |
|
21
|
|
|
* @group plugins |
|
22
|
|
|
*/ |
|
23
|
|
|
class syntax_plugin_yalist_test extends DokuWikiTest { |
|
24
|
|
|
protected $pluginsEnabled = array('yalist'); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* copy data and add pages to the index. |
|
28
|
|
|
*/ |
|
29
|
|
|
public static function setUpBeforeClass(): void { |
|
30
|
|
|
parent::setUpBeforeClass(); |
|
31
|
|
|
global $conf; |
|
32
|
|
|
$conf['allowdebug'] = 1; |
|
33
|
|
|
TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
34
|
|
|
dbglog("\nset up class syntax_plugin_yalist_test"); |
|
35
|
|
|
} |
|
36
|
|
|
function setUp(): void { |
|
|
|
|
|
|
37
|
|
|
parent::setUp(); |
|
38
|
|
|
global $conf; |
|
39
|
|
|
$conf['allowdebug'] = 1; |
|
40
|
|
|
$conf['cachetime'] = -1; |
|
41
|
|
|
$data = array(); |
|
42
|
|
|
search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
43
|
|
|
$verbose = false; |
|
44
|
|
|
$force = false; |
|
45
|
|
|
foreach ($data as $val) { |
|
46
|
|
|
idx_addPage($val['id'], $verbose, $force); |
|
47
|
|
|
} |
|
48
|
|
|
if ($conf['allowdebug']) { |
|
49
|
|
|
touch(DOKU_TMP_DATA . 'cache/debug.log'); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
public function tearDown(): void { |
|
53
|
|
|
parent::tearDown(); |
|
54
|
|
|
global $conf; |
|
55
|
|
|
// try to get the debug log after running the test, print and clear |
|
56
|
|
|
if ($conf['allowdebug']) { |
|
57
|
|
|
print "\n"; |
|
58
|
|
|
readfile(DOKU_TMP_DATA . 'cache/debug.log'); |
|
59
|
|
|
unlink(DOKU_TMP_DATA . 'cache/debug.log'); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testExample(): void { |
|
64
|
|
|
$request = new TestRequest(); |
|
65
|
|
|
$response = $request->get(array('id'=>'example'), '/doku.php'); |
|
66
|
|
|
|
|
67
|
|
|
// save the response html |
|
68
|
|
|
//$handle=fopen('/tmp/data.html', 'w'); |
|
69
|
|
|
//fwrite($handle, $response->getContent()); |
|
70
|
|
|
//fclose($handle); |
|
71
|
|
|
|
|
72
|
|
|
//print_r($response); |
|
73
|
|
|
$this->assertTrue(strpos($response->getContent(), |
|
74
|
|
|
'<h1 class="sectionedit1" id="yalist_example">yalist example</h1> |
|
75
|
|
|
<div class="level1"> |
|
76
|
|
|
<ol> |
|
77
|
|
|
<li class="level1"><div class="li"> |
|
78
|
|
|
Ordered list item 1 |
|
79
|
|
|
</div></li> |
|
80
|
|
|
<li class="level1"><div class="li"> |
|
81
|
|
|
Ordered list item 2 |
|
82
|
|
|
</div></li> |
|
83
|
|
|
<li class="level1"><div class="li"> |
|
84
|
|
|
<p> |
|
85
|
|
|
Ordered list item 3… |
|
86
|
|
|
</p><p> |
|
87
|
|
|
… in multiple paragraphs |
|
88
|
|
|
</p> |
|
89
|
|
|
</div></li> |
|
90
|
|
|
<li class="level1"><div class="li"> |
|
91
|
|
|
Ordered list item 4 |
|
92
|
|
|
</div></li> |
|
93
|
|
|
</ol> |
|
94
|
|
|
|
|
95
|
|
|
<ul> |
|
96
|
|
|
<li class="level1"><div class="li"> |
|
97
|
|
|
Unordered list item |
|
98
|
|
|
</div></li> |
|
99
|
|
|
<li class="level1"><div class="li"> |
|
100
|
|
|
<p> |
|
101
|
|
|
Unordered list item… |
|
102
|
|
|
</p><p> |
|
103
|
|
|
… in multiple paragraphs |
|
104
|
|
|
</p> |
|
105
|
|
|
</div></li> |
|
106
|
|
|
</ul> |
|
107
|
|
|
|
|
108
|
|
|
<ol> |
|
109
|
|
|
<li class="level1"><div class="li"> |
|
110
|
|
|
Ordered list, first level |
|
111
|
|
|
</div><ol> |
|
112
|
|
|
<li class="level2"><div class="li"> |
|
113
|
|
|
Second level |
|
114
|
|
|
</div><ol> |
|
115
|
|
|
<li class="level3"><div class="li"> |
|
116
|
|
|
Third level |
|
117
|
|
|
</div><ol> |
|
118
|
|
|
<li class="level4"><div class="li"> |
|
119
|
|
|
Fourth level |
|
120
|
|
|
</div></li> |
|
121
|
|
|
</ol> |
|
122
|
|
|
</li> |
|
123
|
|
|
</ol> |
|
124
|
|
|
</li> |
|
125
|
|
|
<li class="level2"><div class="li"> |
|
126
|
|
|
<p> |
|
127
|
|
|
Back to second level |
|
128
|
|
|
</p> |
|
129
|
|
|
</div><ol> |
|
130
|
|
|
<li class="level3"><div class="li"> |
|
131
|
|
|
<em>Second?! What happened to third?</em> |
|
132
|
|
|
</div></li> |
|
133
|
|
|
</ol> |
|
134
|
|
|
<div class="li"> |
|
135
|
|
|
<p> |
|
136
|
|
|
<em>Quiet, you.</em> |
|
137
|
|
|
</p> |
|
138
|
|
|
</div></li> |
|
139
|
|
|
</ol> |
|
140
|
|
|
</li> |
|
141
|
|
|
<li class="level1"><div class="li"> |
|
142
|
|
|
Back to first level |
|
143
|
|
|
</div></li> |
|
144
|
|
|
<li class="level1"><div class="li"> |
|
145
|
|
|
Still at first level |
|
146
|
|
|
</div></li> |
|
147
|
|
|
</ol> |
|
148
|
|
|
|
|
149
|
|
|
<dl> |
|
150
|
|
|
<dt class="level1"><span class="dt"> Definition list</span></dt> |
|
151
|
|
|
<dd class="level1"><div class="dd"> |
|
152
|
|
|
Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content. [Source: <abbr title="World Wide Web Consortium">W3C</abbr>] |
|
153
|
|
|
</div></dd> |
|
154
|
|
|
<dt class="level1"><span class="dt"> Definition list w/ multiple paragraphs</span></dt> |
|
155
|
|
|
<dd class="level1"><div class="dd"> |
|
156
|
|
|
<p> |
|
157
|
|
|
The style sheet provided with this plugin will render these paragraphs… |
|
158
|
|
|
</p><p> |
|
159
|
|
|
… to the left of the term being defined. |
|
160
|
|
|
</p> |
|
161
|
|
|
</div><dl> |
|
162
|
|
|
<dt class="level2"><span class="dt"> Definition list w/ multiple “paragraphs”</span></dt> |
|
163
|
|
|
<dd class="level2"><div class="dd"> |
|
164
|
|
|
Another way to separate blocks of text in a definition… |
|
165
|
|
|
</div></dd> |
|
166
|
|
|
<dd class="level2"><div class="dd"> |
|
167
|
|
|
… is to simply have multiple definitions for a term (or group of terms). |
|
168
|
|
|
</div></dd> |
|
169
|
|
|
</dl> |
|
170
|
|
|
</dd> |
|
171
|
|
|
</dl> |
|
172
|
|
|
|
|
173
|
|
|
<dl> |
|
174
|
|
|
<dd class="level1"><div class="dd"> |
|
175
|
|
|
This definition list has DD tags without any preceding DT tags. |
|
176
|
|
|
</div></dd> |
|
177
|
|
|
<dd class="level1"><div class="dd"> |
|
178
|
|
|
Hey, it's legal XHTML. |
|
179
|
|
|
</div></dd> |
|
180
|
|
|
<dt class="level1"><span class="dt"> Just like DT tags without following DD tags.</span></dt> |
|
181
|
|
|
<dt class="level1"><span class="dt">? But DT tags can't contain paragraphs. That would <em class="u">not</em> be legal XHTML.</span></dt> |
|
182
|
|
|
</dl> |
|
183
|
|
|
|
|
184
|
|
|
<pre class="code">.. If you try, the result will be rendered oddly.</pre> |
|
185
|
|
|
|
|
186
|
|
|
</div>') !== false, |
|
187
|
|
|
'expected html snippet was not in the output' |
|
188
|
|
|
); |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.