syntax_plugin_yalist_test   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 172
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 172
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpBeforeClass() 0 7 1
A setUp() 0 16 3
A tearDown() 0 10 2
B testExample() 0 129 1
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
/**
19
 * Syntax tests for the yalist plugin.
20
 *
21
 * @group plugin_yalist
22
 * @group plugins
23
 */
24
class syntax_plugin_yalist_test extends DokuWikiTest {
25
    protected $pluginsEnabled = array('yalist');
26
27
    /**
28
     * copy data and add pages to the index.
29
     */
30
    public static function setUpBeforeClass(): void {
31
        parent::setUpBeforeClass();
32
        global $conf;
33
        $conf['allowdebug'] = 1;
34
        TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/');
35
        dbglog("\nset up class syntax_plugin_yalist_test");
36
    }
37
38
    function setUp(): void {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
39
        parent::setUp();
40
        global $conf;
41
        $conf['allowdebug'] = 1;
42
        $conf['cachetime']  = -1;
43
        $data               = array();
44
        search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true));
45
        $verbose = false;
46
        $force   = false;
47
        foreach($data as $val) {
48
            idx_addPage($val['id'], $verbose, $force);
49
        }
50
        if($conf['allowdebug']) {
51
            touch(DOKU_TMP_DATA . 'cache/debug.log');
52
        }
53
    }
54
55
    public function tearDown(): void {
56
        parent::tearDown();
57
        global $conf;
58
        // try to get the debug log after running the test, print and clear
59
        if($conf['allowdebug']) {
60
            print "\n";
61
            readfile(DOKU_TMP_DATA . 'cache/debug.log');
62
            unlink(DOKU_TMP_DATA . 'cache/debug.log');
63
        }
64
    }
65
66
    public function testExample(): void {
67
        $request  = new TestRequest();
68
        $response = $request->get(array('id' => 'example'), '/doku.php');
69
70
        // save the response html
71
        //$handle=fopen('/tmp/data.html', 'w');
72
        //fwrite($handle, $response->getContent());
73
        //fclose($handle);
74
75
        //print_r($response);
76
        $this->assertNotFalse(
77
            strpos(
78
                $response->getContent(),
79
                '<h1 class="sectionedit1" id="yalist_example">yalist example</h1>
80
<div class="level1">
81
<ol>
82
<li class="level1"><div class="li">
83
 Ordered list item 1
84
</div></li>
85
<li class="level1"><div class="li">
86
 Ordered list item 2
87
</div></li>
88
<li class="level1"><div class="li">
89
<p>
90
 Ordered list item 3…
91
</p><p>
92
 … in multiple paragraphs
93
</p>
94
</div></li>
95
<li class="level1"><div class="li">
96
 Ordered list item 4
97
</div></li>
98
</ol>
99
100
<ul>
101
<li class="level1"><div class="li">
102
 Unordered list item
103
</div></li>
104
<li class="level1"><div class="li">
105
<p>
106
 Unordered list item…
107
</p><p>
108
 … in multiple paragraphs
109
</p>
110
</div></li>
111
</ul>
112
113
<ol>
114
<li class="level1"><div class="li">
115
 Ordered list, first level
116
</div><ol>
117
<li class="level2"><div class="li">
118
 Second level
119
</div><ol>
120
<li class="level3"><div class="li">
121
 Third level
122
</div><ol>
123
<li class="level4"><div class="li">
124
 Fourth level
125
</div></li>
126
</ol>
127
</li>
128
</ol>
129
</li>
130
<li class="level2"><div class="li">
131
<p>
132
 Back to second level
133
</p>
134
</div><ol>
135
<li class="level3"><div class="li">
136
 <em>Second?! What happened to third?</em>
137
</div></li>
138
</ol>
139
<div class="li">
140
<p>
141
 <em>Quiet, you.</em>
142
</p>
143
</div></li>
144
</ol>
145
</li>
146
<li class="level1"><div class="li">
147
 Back to first level
148
</div></li>
149
<li class="level1"><div class="li">
150
 Still at first level
151
</div></li>
152
</ol>
153
154
<dl>
155
<dt class="level1"><span class="dt"> Definition list</span></dt>
156
<dd class="level1"><div class="dd">
157
 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>]
158
</div></dd>
159
<dt class="level1"><span class="dt"> Definition list w/ multiple paragraphs</span></dt>
160
<dd class="level1"><div class="dd">
161
<p>
162
 The style sheet provided with this plugin will render these paragraphs…
163
</p><p>
164
 … to the left of the term being defined.
165
</p>
166
</div><dl>
167
<dt class="level2"><span class="dt"> Definition list w/ multiple “paragraphs”</span></dt>
168
<dd class="level2"><div class="dd">
169
 Another way to separate blocks of text in a definition…
170
</div></dd>
171
<dd class="level2"><div class="dd">
172
 … is to simply have multiple definitions for a term (or group of terms).
173
</div></dd>
174
</dl>
175
</dd>
176
</dl>
177
178
<dl>
179
<dd class="level1"><div class="dd">
180
 This definition list has DD tags without any preceding DT tags.
181
</div></dd>
182
<dd class="level1"><div class="dd">
183
 Hey, it&#039;s legal XHTML.
184
</div></dd>
185
<dt class="level1"><span class="dt"> Just like DT tags without following DD tags.</span></dt>
186
<dt class="level1"><span class="dt">? But DT tags can&#039;t contain paragraphs. That would <em class="u">not</em> be legal XHTML.</span></dt>
187
</dl>
188
189
<pre class="code">.. If you try, the result will be rendered oddly.</pre>
190
191
</div>'
192
            ), 'expected html snippet was not in the output'
193
        );
194
    }
195
}
196