ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
WikiUtilTest Class Reference

Wiki util test. More...

+ Inheritance diagram for WikiUtilTest:
+ Collaboration diagram for WikiUtilTest:

Public Member Functions

 testMakeUrlTitle ()
 
 testMakeDbTitle ()
 
 testProcessInternalLinksExtCollect ()
 
 testProcessInternalLinksExtCollectOneSimple ()
 
 testProcessInternalLinksExtCollectMultipleSimple ()
 
 testProcessInternalLinksExtCollectMultipleSame ()
 
 testProcessInternalLinksExtCollectOneText ()
 
 testProcessInternalLinksExtCollectMultiText ()
 
 testProcessInternalLinksCollectOneSimple ()
 
 testProcessInternalLinksCollectMultipleSame ()
 
 testProcessInternalLinksCollectMultiText ()
 
 testProcessInternalLinksReplaceWithoutLink ()
 

Protected Member Functions

 setGlobalVariable (string $name, $value)
 
 setUp ()
 
 tearDown ()
 
 processInternalLinksExtCollect (string $xml)
 
 processInternalLinksCollect (string $xml)
 
 processInternalLinksReplace (string $xml)
 

Detailed Description

Wiki util test.

Tests mostly mediawiki code.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 29 of file WikiUtilTest.php.

Member Function Documentation

◆ processInternalLinksCollect()

WikiUtilTest::processInternalLinksCollect ( string  $xml)
protected

Definition at line 246 of file WikiUtilTest.php.

246 : array
247 {
249 $xml,
250 0,
251 true,
253 );
254 }
const IL_WIKI_MODE_COLLECT
static collectInternalLinks(string $s, int $a_wiki_id, bool $a_collect_non_ex=false, string $mode=IL_WIKI_MODE_COLLECT)
Collect internal wiki links of a string.

References ilWikiUtil\collectInternalLinks(), and IL_WIKI_MODE_COLLECT.

Referenced by testProcessInternalLinksCollectMultipleSame(), testProcessInternalLinksCollectMultiText(), and testProcessInternalLinksCollectOneSimple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processInternalLinksExtCollect()

WikiUtilTest::processInternalLinksExtCollect ( string  $xml)
protected

◆ processInternalLinksReplace()

WikiUtilTest::processInternalLinksReplace ( string  $xml)
protected

Definition at line 286 of file WikiUtilTest.php.

286 : string
287 {
289 $xml,
290 0,
291 false
292 );
293 }
static replaceInternalLinks(string $s, int $a_wiki_id, bool $a_offline=false, string $lang="-")
This one is based on Mediawiki Parser->replaceInternalLinks since we display images in another way,...

References ilWikiUtil\replaceInternalLinks().

Referenced by testProcessInternalLinksReplaceWithoutLink().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlobalVariable()

WikiUtilTest::setGlobalVariable ( string  $name,
  $value 
)
protected

Definition at line 31 of file WikiUtilTest.php.

31 : void
32 {
33 global $DIC;
34
35 $GLOBALS[$name] = $value;
36
37 unset($DIC[$name]);
38 $DIC[$name] = static function (Container $c) use ($value) {
39 return $value;
40 };
41 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54

References $c, $DIC, and $GLOBALS.

Referenced by setUp().

+ Here is the caller graph for this function:

◆ setUp()

WikiUtilTest::setUp ( )
protected

Definition at line 43 of file WikiUtilTest.php.

43 : void
44 {
45 parent::setUp();
46
47 if (!defined("ILIAS_LOG_ENABLED")) {
48 define("ILIAS_LOG_ENABLED", false);
49 }
51 $GLOBALS['DIC'] = $dic;
52
53 $db_mock = $this->createMock(ilDBInterface::class);
54 $this->setGlobalVariable(
55 "ilDB",
56 $db_mock
57 );
58 }
setGlobalVariable(string $name, $value)
$dic
Definition: ltiresult.php:33

References $dic, $GLOBALS, and setGlobalVariable().

+ Here is the call graph for this function:

◆ tearDown()

WikiUtilTest::tearDown ( )
protected

Definition at line 60 of file WikiUtilTest.php.

60 : void
61 {
62 }

◆ testMakeDbTitle()

WikiUtilTest::testMakeDbTitle ( )

Definition at line 99 of file WikiUtilTest.php.

99 : void
100 {
101 $input_expected = [
102 ["a", "a"]
103 ,["z", "z"]
104 ,["0", "0"]
105 ,[" ", " "]
106 ,["_", " "]
107 ,["!", "!"]
108 ,["§", "§"]
109 ,["$", "$"]
110 ,["%", "%"]
111 ,["&", "&"]
112 ,["/", "/"]
113 ,["(", "("]
114 ,["+", "+"]
115 ,[";", ";"]
116 ,[":", ":"]
117 ,["-", "-"]
118 ,["#", "#"]
119 ,["?", "?"]
120 ,["\x00", ""]
121 ,["\n", ""]
122 ,["\r", ""]
123 ];
124 foreach ($input_expected as $ie) {
125 $result = ilWikiUtil::makeDbTitle($ie[0]);
126
127 $this->assertEquals(
128 $ie[1],
129 $result
130 );
131 }
132 }
static makeDbTitle(string $a_par)

References ilWikiUtil\makeDbTitle().

+ Here is the call graph for this function:

◆ testMakeUrlTitle()

WikiUtilTest::testMakeUrlTitle ( )

Definition at line 64 of file WikiUtilTest.php.

64 : void
65 {
66 $input_expected = [
67 ["a", "a"]
68 ,["z", "z"]
69 ,["0", "0"]
70 ,[" ", "_"]
71 ,["_", "_"]
72 ,["!", "%21"]
73 ,["§", "%C2%A7"]
74 ,["$", "%24"]
75 ,["%", "%25"]
76 ,["&", "%26"]
77 ,["/", "%2F"]
78 ,["(", "%28"]
79 ,["+", "%2B"]
80 ,[";", "%3B"]
81 ,[":", "%3A"]
82 ,["-", "-"]
83 ,["#", "%23"]
84 ,["?", "%3F"]
85 ,["\x00", ""]
86 ,["\n", ""]
87 ,["\r", ""]
88 ];
89 foreach ($input_expected as $ie) {
90 $result = ilWikiUtil::makeUrlTitle($ie[0]);
91
92 $this->assertEquals(
93 $ie[1],
94 $result
95 );
96 }
97 }
static makeUrlTitle(string $a_par)

References ilWikiUtil\makeUrlTitle().

+ Here is the call graph for this function:

◆ testProcessInternalLinksCollectMultipleSame()

WikiUtilTest::testProcessInternalLinksCollectMultipleSame ( )

Definition at line 266 of file WikiUtilTest.php.

266 : void
267 {
268 $xml = "<Foo>[[bar]]</Foo><Par>[[bar1]] some text [[bar]]</Par>";
269 $r = $this->processInternalLinksCollect($xml);
270 $this->assertEquals(
271 ["bar", "bar1"],
272 $r
273 );
274 }
processInternalLinksCollect(string $xml)

References processInternalLinksCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksCollectMultiText()

WikiUtilTest::testProcessInternalLinksCollectMultiText ( )

Definition at line 276 of file WikiUtilTest.php.

276 : void
277 {
278 $xml = "<Foo>lore [[bar|some text]] ipsum</Foo><Par>More [[second link|some text for second]]</Par>";
279 $r = $this->processInternalLinksCollect($xml);
280 $this->assertEquals(
281 ["bar", "second link"],
282 $r
283 );
284 }

References processInternalLinksCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksCollectOneSimple()

WikiUtilTest::testProcessInternalLinksCollectOneSimple ( )

Definition at line 256 of file WikiUtilTest.php.

256 : void
257 {
258 $xml = "<Foo>[[bar]]</Foo>";
259 $r = $this->processInternalLinksCollect($xml);
260 $this->assertEquals(
261 ["bar"],
262 $r
263 );
264 }

References processInternalLinksCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksExtCollect()

WikiUtilTest::testProcessInternalLinksExtCollect ( )

Definition at line 144 of file WikiUtilTest.php.

144 : void
145 {
146 $input_expected = [
147 ["", []]
148 ,["<Foo></Foo>", []]
149 ];
150 foreach ($input_expected as $ie) {
151 $result = $this->processInternalLinksExtCollect($ie[0]);
152
153 $this->assertEquals(
154 $ie[1],
155 $result
156 );
157 }
158 }
processInternalLinksExtCollect(string $xml)

References processInternalLinksExtCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksExtCollectMultipleSame()

WikiUtilTest::testProcessInternalLinksExtCollectMultipleSame ( )

Definition at line 192 of file WikiUtilTest.php.

192 : void
193 {
194 $xml = "<Foo>[[bar]]</Foo><Par>[[bar1]] some text [[bar]]</Par>";
195 $r = $this->processInternalLinksExtCollect($xml);
196 $this->assertEquals(
197 "bar",
198 $r[0]["nt"]->mTextform
199 );
200 $this->assertEquals(
201 "bar1",
202 $r[1]["nt"]->mTextform
203 );
204 $this->assertEquals(
205 "bar",
206 $r[2]["nt"]->mTextform
207 );
208 }

References processInternalLinksExtCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksExtCollectMultipleSimple()

WikiUtilTest::testProcessInternalLinksExtCollectMultipleSimple ( )

Definition at line 174 of file WikiUtilTest.php.

174 : void
175 {
176 $xml = "<Foo>[[bar]]</Foo><Par>[[bar1]] some text [[bar2]]</Par>";
177 $r = $this->processInternalLinksExtCollect($xml);
178 $this->assertEquals(
179 "bar",
180 $r[0]["nt"]->mTextform
181 );
182 $this->assertEquals(
183 "bar1",
184 $r[1]["nt"]->mTextform
185 );
186 $this->assertEquals(
187 "bar2",
188 $r[2]["nt"]->mTextform
189 );
190 }

References processInternalLinksExtCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksExtCollectMultiText()

WikiUtilTest::testProcessInternalLinksExtCollectMultiText ( )

Definition at line 224 of file WikiUtilTest.php.

224 : void
225 {
226 $xml = "<Foo>lore [[bar|some text]] ipsum</Foo><Par>More [[second link|some text for second]]</Par>";
227 $r = $this->processInternalLinksExtCollect($xml);
228 $this->assertEquals(
229 "bar",
230 $r[0]["nt"]->mTextform
231 );
232 $this->assertEquals(
233 "some text",
234 $r[0]["text"]
235 );
236 $this->assertEquals(
237 "second link",
238 $r[1]["nt"]->mTextform
239 );
240 $this->assertEquals(
241 "some text for second",
242 $r[1]["text"]
243 );
244 }

References processInternalLinksExtCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksExtCollectOneSimple()

WikiUtilTest::testProcessInternalLinksExtCollectOneSimple ( )

Definition at line 160 of file WikiUtilTest.php.

160 : void
161 {
162 $xml = "<Foo>[[bar]]</Foo>";
163 $r = $this->processInternalLinksExtCollect($xml);
164 $this->assertEquals(
165 "bar",
166 $r[0]["nt"]->mTextform
167 );
168 $this->assertEquals(
169 "bar",
170 $r[0]["text"]
171 );
172 }

References processInternalLinksExtCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksExtCollectOneText()

WikiUtilTest::testProcessInternalLinksExtCollectOneText ( )

Definition at line 210 of file WikiUtilTest.php.

210 : void
211 {
212 $xml = "<Foo>[[bar|some text]]</Foo>";
213 $r = $this->processInternalLinksExtCollect($xml);
214 $this->assertEquals(
215 "bar",
216 $r[0]["nt"]->mTextform
217 );
218 $this->assertEquals(
219 "some text",
220 $r[0]["text"]
221 );
222 }

References processInternalLinksExtCollect().

+ Here is the call graph for this function:

◆ testProcessInternalLinksReplaceWithoutLink()

WikiUtilTest::testProcessInternalLinksReplaceWithoutLink ( )

Definition at line 295 of file WikiUtilTest.php.

295 : void
296 {
297 $xml = "<Foo>Some text without a link</Par>";
298 $r = $this->processInternalLinksReplace($xml);
299 $this->assertEquals(
300 $xml,
301 $r
302 );
303 }
processInternalLinksReplace(string $xml)

References processInternalLinksReplace().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: