ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
PCParagraphTest Class Reference
+ Inheritance diagram for PCParagraphTest:
+ Collaboration diagram for PCParagraphTest:

Public Member Functions

 test_input2xmlEmpty ()
 Test _input2xml (empty) More...
 
 test_input2xmlValidXml ()
 Test _input2xml for validity. More...
 
 test_input2xmlResult ()
 Test _input2xml. More...
 
 testHandleAjaxContentPost ()
 Test handleAjaxContentPost. More...
 
 testHandleAjaxContentSpans ()
 Test HTML to BB transformation, spans. More...
 
 testHandleAjaxContentLists ()
 Test HTML to BB transformation, lists (are not transformed in this first step) More...
 
 testConstruction ()
 
 testCreate ()
 
 testLegacyHtml2Text ()
 
 testCharacteristic ()
 
 testSubCharacteristic ()
 
 testAutoIndent ()
 
 testDownloadTitle ()
 
 testShowLineNumbers ()
 
 testLanguage ()
 

Additional Inherited Members

- Protected Member Functions inherited from COPageTestBase
 setGlobalVariable (string $name, $value)
 
 setUp ()
 
 getIdGeneratorMock ()
 
 getPCDefinition ()
 
 setPCIdCnt (int $cnt)
 
 getIDManager (\ilPageObject $page)
 
 insertParagraphAt (\ilPageObject $page, string $hier_id, string $text="")
 
 tearDown ()
 
 normalize (string $html)
 
 assertXmlEquals (string $expected_xml_as_string, string $html_xml_string)
 
 getEmptyPageWithDom ()
 
 legacyHtmlToXml (string $content)
 
 getMediaObjectMock ()
 
- Protected Attributes inherited from COPageTestBase
int $pc_cnt
 

Detailed Description

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

Definition at line 24 of file PCParagraphTest.php.

Member Function Documentation

◆ test_input2xmlEmpty()

PCParagraphTest::test_input2xmlEmpty ( )

Test _input2xml (empty)

Definition at line 34 of file PCParagraphTest.php.

34 : void
35 {
36 $res = ilPCParagraph::_input2xml("", "en", true, false);
37 $this->assertEquals(
38 "",
39 $res
40 );
41 }
static _input2xml(string $a_text, string $a_lang, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Converts user input to xml User input comes as bb code information, e.g.
foreach($_POST as $key=> $value) $res

References $res, and ilPCParagraph\_input2xml().

+ Here is the call graph for this function:

◆ test_input2xmlResult()

PCParagraphTest::test_input2xmlResult ( )

Test _input2xml.

Definition at line 75 of file PCParagraphTest.php.

75 : void
76 {
77 $cases = [
78 ''
79 => '',
80 'xx'
81 => 'xx',
82
83 // text mark-up
84 'xx [str]xx[/str] xx'
85 => 'xx <Strong>xx</Strong> xx',
86 'xx [com]xx[/com] xx'
87 => 'xx <Comment>xx</Comment> xx',
88 'xx [emp]xx[/emp] xx'
89 => 'xx <Emph>xx</Emph> xx',
90 'xx [fn]xx[/fn] xx'
91 => 'xx <Footnote>xx</Footnote> xx',
92 'xx [code]xx[/code] xx'
93 => 'xx <Code>xx</Code> xx',
94 'xx [acc]xx[/acc] xx'
95 => 'xx <Accent>xx</Accent> xx',
96 'xx [imp]xx[/imp] xx'
97 => 'xx <Important>xx</Important> xx',
98 'xx [kw]xx[/kw] xx'
99 => 'xx <Keyw>xx</Keyw> xx',
100 'xx [sub]xx[/sub] xx'
101 => 'xx <Sub>xx</Sub> xx',
102 'xx [sup]xx[/sup] xx'
103 => 'xx <Sup>xx</Sup> xx',
104 'xx [quot]xx[/quot] xx'
105 => 'xx <Quotation>xx</Quotation> xx',
106
107 // internal links
108 'xx [iln cat="106"] xx [/iln] xx'
109 => 'xx <IntLink Target="il__obj_106" Type="RepositoryItem"> xx </IntLink> xx',
110 'xx [iln cat="106" anchor="moin"] xx [/iln] xx'
111 => 'xx <IntLink Target="il__obj_106" Type="RepositoryItem" Anchor="moin"> xx </IntLink> xx',
112 'xx [iln page="106"] xx [/iln] xx'
113 => 'xx <IntLink Target="il__pg_106" Type="PageObject"> xx </IntLink> xx',
114 'xx [iln page="106"] xx xx'
115 => 'xx xx xx',
116 'xx xx [/iln] xx'
117 => 'xx xx [/iln] xx',
118 'xx [iln chap="106"] xx [/iln] xx'
119 => 'xx <IntLink Target="il__st_106" Type="StructureObject"> xx </IntLink> xx',
120 'xx [iln inst="123" page="106"] xx [/iln] xx'
121 => 'xx <IntLink Target="il_123_pg_106" Type="PageObject"> xx </IntLink> xx',
122 'xx [iln page="106" target="FAQ"] xx [/iln] xx'
123 => 'xx <IntLink Target="il__pg_106" Type="PageObject" TargetFrame="FAQ"> xx </IntLink> xx',
124 'xx [iln page="106" target="New" anchor="test"] xx [/iln] xx'
125 => 'xx <IntLink Target="il__pg_106" Type="PageObject" TargetFrame="New" Anchor="test"> xx </IntLink> xx',
126 'xx [iln term="106"] xx [/iln] xx'
127 => 'xx <IntLink Target="il__git_106" Type="GlossaryItem" TargetFrame="Glossary"> xx </IntLink> xx',
128 'xx [iln term="106" target="New"] xx [/iln] xx'
129 => 'xx <IntLink Target="il__git_106" Type="GlossaryItem" TargetFrame="New"> xx </IntLink> xx',
130 'xx [iln wpage="106"] xx [/iln] xx'
131 => 'xx <IntLink Target="il__wpage_106" Type="WikiPage"> xx </IntLink> xx',
132 'xx [iln wpage="106" anchor="test"] xx [/iln] xx'
133 => 'xx <IntLink Target="il__wpage_106" Type="WikiPage" Anchor="test"> xx </IntLink> xx',
134 'xx [iln ppage="106"] xx [/iln] xx'
135 => 'xx <IntLink Target="il__ppage_106" Type="PortfolioPage"> xx </IntLink> xx',
136 'xx [iln media="545"/] xx '
137 => 'xx <IntLink Target="il__mob_545" Type="MediaObject"/> xx',
138 'xx [iln media="108" target="New"] xx [/iln] xx'
139 => 'xx <IntLink Target="il__mob_108" Type="MediaObject" TargetFrame="New"> xx </IntLink> xx',
140 'xx [iln media="108" target="Media"] xx [/iln] xx'
141 => 'xx <IntLink Target="il__mob_108" Type="MediaObject" TargetFrame="Media"> xx </IntLink> xx',
142 'xx [iln dfile="546"] xx [/iln] xx'
143 => 'xx <IntLink Target="il__dfile_546" Type="File"> xx </IntLink> xx',
144
145 // returns
146 'xx' . chr(13) . chr(10) . 'yy'
147 => 'xx<br />yy',
148 'xx' . chr(13) . 'yy'
149 => 'xx<br />yy',
150 'xx' . chr(10) . 'yy'
151 => 'xx<br />yy',
152
153 // lists
154 '<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">aa</li><li class="ilc_list_item_StandardListItem">bb</li><li class="ilc_list_item_StandardListItem">cc</li></ul>'
155 => '&lt;ul class="ilc_list_u_BulletedList"&gt;&lt;li class="ilc_list_item_StandardListItem"&gt;aa&lt;/li&gt;&lt;li class="ilc_list_item_StandardListItem"&gt;bb&lt;/li&gt;&lt;li class="ilc_list_item_StandardListItem"&gt;cc&lt;/li&gt;&lt;/ul&gt;',
156
157 // external links
158 'xx [xln url="http://"][/xln] xxxx'
159 => 'xx xxxx',
160 'xx [xln url="http://ilias.de"]www[/xln] xxxx'
161 => 'xx <ExtLink Href="http://ilias.de">www</ExtLink> xxxx',
162 'xx [xln url="http://ilias.php?x=1&y=2"]www[/xln] xxxx'
163 => 'xx <ExtLink Href="http://ilias.php?x=1&y=2">www</ExtLink> xxxx',
164 'xx [xln url="https://bs.lehrplan.ch/index.php?code=a|10|0|1|0|1"]curriculum[/xln] xxxx'
165 => 'xx <ExtLink Href="https://bs.lehrplan.ch/index.php?code=a|10|0|1|0|1">curriculum</ExtLink> xxxx',
166 'xx [xln url="http://ilias.de/my+document.pdf"]doc[/xln] xxxx'
167 => 'xx <ExtLink Href="http://ilias.de/my+document.pdf">doc</ExtLink> xxxx',
168 'xx [xln url="http://ilias.de/my(document.pdf"]doc[/xln] xxxx'
169 => 'xx <ExtLink Href="http://ilias.de/my(document.pdf">doc</ExtLink> xxxx',
170 'xx [xln url="http://ilias.de/my)document.pdf"]doc[/xln] xxxx'
171 => 'xx <ExtLink Href="http://ilias.de/my)document.pdf">doc</ExtLink> xxxx',
172 'xx [xln url="http://ilias.de/my$document.pdf"]doc[/xln] xxxx'
173 => 'xx <ExtLink Href="http://ilias.de/my$document.pdf">doc</ExtLink> xxxx',
174 'xx [xln url="http://ilias.de/my*document.pdf"]doc[/xln] xxxx'
175 => 'xx <ExtLink Href="http://ilias.de/my*document.pdf">doc</ExtLink> xxxx',
176
177 // anchor
178 'xx [anc name="test"]test[/anc] xxxx'
179 => 'xx <Anchor Name="test">test</Anchor> xxxx',
180
181 // marked
182 'xx [marked class="test"]test[/marked] xxxx'
183 => 'xx <Marked Class="test">test</Marked> xxxx',
184
185 // non-break space
186 "xx \n \xa0 xxxx"
187 => "xx <br /> \xa0 xxxx",
188
189 'xx [xln url="http://ilias.de/my+document.pdf\xa0"]doc[/xln] xxxx'
190 => 'xx [error: xln url="http://ilias.de/my+document.pdf\xa0"]doc</ExtLink> xxxx',
191
192 /*'xx [iln cat="106"] xx'
193 => 'xx [iln cat="106"] xx',
194 'xx [/iln] xx'
195 => 'xx [/iln] xx'*/
196 ];
197
198 foreach ($cases as $in => $expected) {
199 $out = ilPCParagraph::_input2xml($in, "en", true, false);
200 $this->assertEquals(
201 $expected,
202 $out
203 );
204 }
205 }
$out
Definition: buildRTE.php:24

References $out, and ilPCParagraph\_input2xml().

+ Here is the call graph for this function:

◆ test_input2xmlValidXml()

PCParagraphTest::test_input2xmlValidXml ( )

Test _input2xml for validity.

Definition at line 46 of file PCParagraphTest.php.

46 : void
47 {
48 $cases = [
49 '',
50 'xx',
51 'xx [str]xx[/str] xx',
52 'xx [iln cat="106"] xx',
53 'xx [/iln] xx',
54 ];
55
56 foreach ($cases as $case) {
57 $text = ilPCParagraph::_input2xml($case, "en", true, false);
58 $use_internal_errors = libxml_use_internal_errors(true);
59 $sxe = simplexml_load_string("<?xml version='1.0'?><dummy>" . $text . "</dummy>");
60 libxml_use_internal_errors($use_internal_errors);
61 $res = true;
62 if ($sxe === false) {
63 $res = $text;
64 }
65 $this->assertEquals(
66 true,
67 $res
68 );
69 }
70 }
$text
Definition: xapiexit.php:21

References $res, $text, and ilPCParagraph\_input2xml().

+ Here is the call graph for this function:

◆ testAutoIndent()

PCParagraphTest::testAutoIndent ( )

Definition at line 508 of file PCParagraphTest.php.

508 : void
509 {
510 $page = $this->getEmptyPageWithDom();
511 $pc = new ilPCParagraph($page);
512 $pc->create($page, "pg");
513 $pc->setLanguage("en");
514 $pc->setAutoIndent("1");
515
516 $this->assertEquals(
517 "1",
518 $pc->getAutoIndent()
519 );
520 $page->stripHierIDs();
521
522 $expected = <<<EOT
523<PageObject><PageContent><Paragraph Language="en" AutoIndent="1"></Paragraph></PageContent></PageObject>
524EOT;
525 $this->assertXmlEquals(
526 $expected,
527 $page->getXMLFromDom()
528 );
529 }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testCharacteristic()

PCParagraphTest::testCharacteristic ( )

Definition at line 462 of file PCParagraphTest.php.

462 : void
463 {
464 $page = $this->getEmptyPageWithDom();
465 $pc = new ilPCParagraph($page);
466 $pc->create($page, "pg");
467 $pc->setLanguage("en");
468 $pc->setCharacteristic("MyChar");
469
470 $this->assertEquals(
471 "MyChar",
472 $pc->getCharacteristic()
473 );
474 $page->stripHierIDs();
475
476 $expected = <<<EOT
477<PageObject><PageContent><Paragraph Language="en" Characteristic="MyChar"></Paragraph></PageContent></PageObject>
478EOT;
479 $this->assertXmlEquals(
480 $expected,
481 $page->getXMLFromDom()
482 );
483 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testConstruction()

PCParagraphTest::testConstruction ( )

Definition at line 400 of file PCParagraphTest.php.

400 : void
401 {
402 $page = $this->getEmptyPageWithDom();
403 $pc = new ilPCParagraph($page);
404 $this->assertEquals(
405 ilPCParagraph::class,
406 get_class($pc)
407 );
408 }

References $page, and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testCreate()

PCParagraphTest::testCreate ( )

Definition at line 410 of file PCParagraphTest.php.

410 : void
411 {
412 $page = $this->getEmptyPageWithDom();
413 $pc = new ilPCParagraph($page);
414 $pc->create($page, "pg");
415 $this->assertXmlEquals(
416 '<PageObject HierId="pg"><PageContent><Paragraph Language=""></Paragraph></PageContent></PageObject>',
417 $page->getXMLFromDom()
418 );
419 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testDownloadTitle()

PCParagraphTest::testDownloadTitle ( )

Definition at line 531 of file PCParagraphTest.php.

531 : void
532 {
533 $page = $this->getEmptyPageWithDom();
534 $pc = new ilPCParagraph($page);
535 $pc->create($page, "pg");
536 $pc->setLanguage("en");
537 $pc->setDownloadTitle("title.txt");
538
539 $this->assertEquals(
540 "title.txt",
541 $pc->getDownloadTitle()
542 );
543 $page->stripHierIDs();
544
545 $expected = <<<EOT
546<PageObject><PageContent><Paragraph Language="en" DownloadTitle="title.txt"></Paragraph></PageContent></PageObject>
547EOT;
548 $this->assertXmlEquals(
549 $expected,
550 $page->getXMLFromDom()
551 );
552 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testHandleAjaxContentLists()

PCParagraphTest::testHandleAjaxContentLists ( )

Test HTML to BB transformation, lists (are not transformed in this first step)

Definition at line 360 of file PCParagraphTest.php.

360 : void
361 {
362 $cases = [
363 // List, Bullet
364 '<div id="1:1234" class="ilc_text_block_List"><ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ul></div>'
365 => [
366 "text" => '<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ul>',
367 "id" => '1:1234',
368 "class" => 'List'
369 ],
370 // List, Numberd
371 '<div id="1:1235" class="ilc_text_block_List"><ol class="ilc_list_o_NumberedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ol></div>'
372 => [
373 "text" => '<ol class="ilc_list_o_NumberedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ol>',
374 "id" => '1:1235',
375 "class" => 'List'
376 ],
377 ];
378
379 foreach ($cases as $in => $expected) {
381 $this->assertEquals(
382 $expected["text"],
383 $out["text"]
384 );
385 $this->assertEquals(
386 $expected["id"],
387 $out["id"]
388 );
389 $this->assertEquals(
390 $expected["class"],
391 $out["class"]
392 );
393 }
394 }
static handleAjaxContent(string $a_content)
Handle ajax content.

References $out, and ilPCParagraph\handleAjaxContent().

+ Here is the call graph for this function:

◆ testHandleAjaxContentPost()

PCParagraphTest::testHandleAjaxContentPost ( )

Test handleAjaxContentPost.

Definition at line 210 of file PCParagraphTest.php.

210 : void
211 {
212 $cases = [
213 '&lt;ul class="ilc_list_u_BulletedList"&gt;&lt;li class="ilc_list_item_StandardListItem"&gt;aa&lt;/li&gt;&lt;li class="ilc_list_item_StandardListItem"&gt;bb&lt;/li&gt;&lt;li class="ilc_list_item_StandardListItem"&gt;cc&lt;/li&gt;&lt;/ul&gt;'
214 => '<SimpleBulletList Class="BulletedList"><SimpleListItem Class="StandardListItem">aa</SimpleListItem><SimpleListItem Class="StandardListItem">bb</SimpleListItem><SimpleListItem Class="StandardListItem">cc</SimpleListItem></SimpleBulletList>',
215 '&lt;ul class="ilc_list_u_BulletedList"&gt;&lt;li class="ilc_list_item_StandardListItem"/&gt;&lt;/ul&gt;'
216 => '<SimpleBulletList Class="BulletedList"><SimpleListItem Class="StandardListItem"></SimpleListItem></SimpleBulletList>'
217 ];
218
219 foreach ($cases as $in => $expected) {
221 $this->assertEquals(
222 $expected,
223 $out
224 );
225 }
226 }
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.

References $out, and ilPCParagraph\handleAjaxContentPost().

+ Here is the call graph for this function:

◆ testHandleAjaxContentSpans()

PCParagraphTest::testHandleAjaxContentSpans ( )

Test HTML to BB transformation, spans.

Definition at line 231 of file PCParagraphTest.php.

231 : void
232 {
233 $cases = [
234 // Table cells send HTML line breaks directly to handleAjaxContent.
235 '<div>First<br>Second<br><br>Fourth</div>'
236 => [
237 "text" => "First\nSecond\n\nFourth",
238 "id" => '',
239 "class" => 'Standard'
240 ],
241 '<div>First<br />Second<br/>Third</div>'
242 => [
243 "text" => "First\nSecond\nThird",
244 "id" => '',
245 "class" => 'Standard'
246 ],
247 // Standard, Strong
248 '<div id="1:1234" class="ilc_text_block_Standard">xxx<span class="ilc_text_inline_Strong">xxx</span>xxx</div>'
249 => [
250 "text" => 'xxx[str]xxx[/str]xxx',
251 "id" => '1:1234',
252 "class" => 'Standard'
253 ],
254 // Mnemonic, Emphatic
255 '<div id="1:1235" class="ilc_text_block_Mnemonic">xxx<span class="ilc_text_inline_Emph">xxx</span>xxx</div>'
256 => [
257 "text" => 'xxx[emp]xxx[/emp]xxx',
258 "id" => '1:1235',
259 "class" => 'Mnemonic'
260 ],
261 // Headline1, Important
262 '<div id="1:1236" class="ilc_text_block_Headline1">xxx<span class="ilc_text_inline_Important">xxx</span>xxx</div>'
263 => [
264 "text" => 'xxx[imp]xxx[/imp]xxx',
265 "id" => '1:1236',
266 "class" => 'Headline1'
267 ],
268 // Standard, Sup
269 '<div id="1:1237" class="ilc_text_block_Standard">xxx a<sup class="ilc_sup_Sup">b*c</sup> xxx</div>'
270 => [
271 "text" => 'xxx a[sup]b*c[/sup] xxx',
272 "id" => '1:1237',
273 "class" => 'Standard'
274 ],
275 // Standard, Sub
276 '<div id="1:1238" class="ilc_text_block_Standard">xxx a<sub class="ilc_sub_Sub">2</sub> xxx</div>'
277 => [
278 "text" => 'xxx a[sub]2[/sub] xxx',
279 "id" => '1:1238',
280 "class" => 'Standard'
281 ],
282 // Standard, Sup (without class, e.g. coming from word)
283 '<div id="1:1237" class="ilc_text_block_Standard">xxx a<sup>b*c</sup> xxx</div>'
284 => [
285 "text" => 'xxx a[sup]b*c[/sup] xxx',
286 "id" => '1:1237',
287 "class" => 'Standard'
288 ],
289 // Standard, Sub (without class, e.g. coming from word)
290 '<div id="1:1238" class="ilc_text_block_Standard">xxx a<sub>2</sub> xxx</div>'
291 => [
292 "text" => 'xxx a[sub]2[/sub] xxx',
293 "id" => '1:1238',
294 "class" => 'Standard'
295 ],
296 // Headline2, Comment
297 '<div id="1:1239" class="ilc_text_block_Headline2">xxx <span class="ilc_text_inline_Comment">xxx</span> xxx</div>'
298 => [
299 "text" => 'xxx [com]xxx[/com] xxx',
300 "id" => '1:1239',
301 "class" => 'Headline2'
302 ],
303 // Headline3, Comment
304 '<div id="1:1240" class="ilc_text_block_Headline3">xxx <span class="ilc_text_inline_Quotation">xxx</span> xxx</div>'
305 => [
306 "text" => 'xxx [quot]xxx[/quot] xxx',
307 "id" => '1:1240',
308 "class" => 'Headline3'
309 ],
310 // Book, Accent
311 '<div id="1:1241" class="ilc_text_block_Book">xxx <span class="ilc_text_inline_Accent">xxx</span> xxx</div>'
312 => [
313 "text" => 'xxx [acc]xxx[/acc] xxx',
314 "id" => '1:1241',
315 "class" => 'Book'
316 ],
317 // Numbers, Code
318 '<div id="1:1242" class="ilc_text_block_Numbers">xxx <code>xxx</code> xxx</div>'
319 => [
320 "text" => 'xxx [code]xxx[/code] xxx',
321 "id" => '1:1242',
322 "class" => 'Numbers'
323 ],
324 // Verse, Mnemonic
325 '<div id="1:1243" class="ilc_text_block_Verse">xxx <span class="ilc_text_inline_Mnemonic">xxx</span> xxx</div>'
326 => [
327 "text" => 'xxx [marked class="Mnemonic"]xxx[/marked] xxx',
328 "id" => '1:1243',
329 "class" => 'Verse'
330 ],
331 // List, Attention
332 '<div id="1:1244" class="ilc_text_block_List">xxx <span class="ilc_text_inline_Attention">xxx</span> xxx</div>'
333 => [
334 "text" => 'xxx [marked class="Attention"]xxx[/marked] xxx',
335 "id" => '1:1244',
336 "class" => 'List'
337 ],
338 ];
339
340 foreach ($cases as $in => $expected) {
342 $this->assertEquals(
343 $expected["text"],
344 $out["text"]
345 );
346 $this->assertEquals(
347 $expected["id"],
348 $out["id"]
349 );
350 $this->assertEquals(
351 $expected["class"],
352 $out["class"]
353 );
354 }
355 }

References $out, and ilPCParagraph\handleAjaxContent().

+ Here is the call graph for this function:

◆ testLanguage()

PCParagraphTest::testLanguage ( )

Definition at line 577 of file PCParagraphTest.php.

577 : void
578 {
579 $page = $this->getEmptyPageWithDom();
580 $pc = new ilPCParagraph($page);
581 $pc->create($page, "pg");
582 $pc->setLanguage("en");
583
584 $this->assertEquals(
585 "en",
586 $pc->getLanguage()
587 );
588 $page->stripHierIDs();
589
590 $expected = <<<EOT
591<PageObject><PageContent><Paragraph Language="en"></Paragraph></PageContent></PageObject>
592EOT;
593 $this->assertXmlEquals(
594 $expected,
595 $page->getXMLFromDom()
596 );
597 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testLegacyHtml2Text()

PCParagraphTest::testLegacyHtml2Text ( )

Definition at line 426 of file PCParagraphTest.php.

426 : void
427 {
428 $page = $this->getEmptyPageWithDom();
429 $pc = new ilPCParagraph($page);
430 $pc->create($page, "pg");
431
432 $cases = [
433 ''
434 => '',
435 'Some text'
436 => 'Some text',
437 'test &amp; the &lt; and the &gt; and the \ also'
438 => 'test &amp;amp; the &amp;lt; and the &amp;gt; and the \ also',
439 'xxx <span class="ilc_text_inline_Strong">xxx</span> xxx'
440 => 'xxx <Strong>xxx</Strong> xxx',
441 ];
442
443 foreach ($cases as $html => $expected) {
444 $html = '<div id="1:1234" class="ilc_text_block_Standard">' . $html . '</div>';
445 $xml = $this->legacyHtmlToXml($html);
446 $pc->setText($xml, false);
447
448 $expected = '<PageObject HierId="pg"><PageContent><Paragraph Language="">' . $expected . '</Paragraph></PageContent></PageObject>';
449
450 $this->assertEquals(
451 $xml,
452 $pc->getText()
453 );
454
455 $this->assertXmlEquals(
456 $expected,
457 $page->getXMLFromDom()
458 );
459 }
460 }
legacyHtmlToXml(string $content)

References $page, COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\legacyHtmlToXml().

+ Here is the call graph for this function:

◆ testShowLineNumbers()

PCParagraphTest::testShowLineNumbers ( )

Definition at line 554 of file PCParagraphTest.php.

554 : void
555 {
556 $page = $this->getEmptyPageWithDom();
557 $pc = new ilPCParagraph($page);
558 $pc->create($page, "pg");
559 $pc->setLanguage("en");
560 $pc->setShowLineNumbers("y");
561
562 $this->assertEquals(
563 "y",
564 $pc->getShowLineNumbers()
565 );
566 $page->stripHierIDs();
567
568 $expected = <<<EOT
569<PageObject><PageContent><Paragraph Language="en" ShowLineNumbers="y"></Paragraph></PageContent></PageObject>
570EOT;
571 $this->assertXmlEquals(
572 $expected,
573 $page->getXMLFromDom()
574 );
575 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testSubCharacteristic()

PCParagraphTest::testSubCharacteristic ( )

Definition at line 485 of file PCParagraphTest.php.

485 : void
486 {
487 $page = $this->getEmptyPageWithDom();
488 $pc = new ilPCParagraph($page);
489 $pc->create($page, "pg");
490 $pc->setLanguage("en");
491 $pc->setSubCharacteristic("MySubChar");
492
493 $this->assertEquals(
494 "MySubChar",
495 $pc->getSubCharacteristic()
496 );
497 $page->stripHierIDs();
498
499 $expected = <<<EOT
500<PageObject><PageContent><Paragraph Language="en" SubCharacteristic="MySubChar"></Paragraph></PageContent></PageObject>
501EOT;
502 $this->assertXmlEquals(
503 $expected,
504 $page->getXMLFromDom()
505 );
506 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

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