ILIAS  release_8 Revision v8.24
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...
 

Protected Member Functions

 setGlobalVariable (string $name, $value)
 
 setUp ()
 
 tearDown ()
 

Detailed Description

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

Definition at line 8 of file PCParagraphTest.php.

Member Function Documentation

◆ setGlobalVariable()

PCParagraphTest::setGlobalVariable ( string  $name,
  $value 
)
protected
Parameters
mixed$value

Definition at line 13 of file PCParagraphTest.php.

13 : void
14 {
15 global $DIC;
16
17 $GLOBALS[$name] = $value;
18
19 unset($DIC[$name]);
20 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
21 return $value;
22 };
23 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247

References $c, $DIC, $GLOBALS, and $name.

Referenced by setUp().

+ Here is the caller graph for this function:

◆ setUp()

PCParagraphTest::setUp ( )
protected

Definition at line 25 of file PCParagraphTest.php.

25 : void
26 {
28 $GLOBALS['DIC'] = $dic;
29
30 if (!defined("COPAGE_TEST")) {
31 define("COPAGE_TEST", "1");
32 }
33 parent::setUp();
34
35 $def_mock = $this->getMockBuilder(ilObjectDefinition::class)
36 ->disableOriginalConstructor()
37 ->getMock();
38
39 $def_mock
40 ->method('getAllRepositoryTypes')
41 ->willReturn(["crs", "grp", "cat"]);
42 $this->setGlobalVariable(
43 "objDefinition",
44 $def_mock
45 );
46 }
setGlobalVariable(string $name, $value)
$dic
Definition: result.php:32

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

+ Here is the call graph for this function:

◆ tearDown()

PCParagraphTest::tearDown ( )
protected

Definition at line 48 of file PCParagraphTest.php.

48 : void
49 {
50 }

◆ test_input2xmlEmpty()

PCParagraphTest::test_input2xmlEmpty ( )

Test _input2xml (empty)

Definition at line 55 of file PCParagraphTest.php.

55 : void
56 {
57 $res = ilPCParagraph::_input2xml("", "en", true, false);
58 $this->assertEquals(
59 "",
60 $res
61 );
62 }
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.
$res
Definition: ltiservices.php:69

References $res, and ilPCParagraph\_input2xml().

+ Here is the call graph for this function:

◆ test_input2xmlResult()

PCParagraphTest::test_input2xmlResult ( )

Test _input2xml.

Definition at line 96 of file PCParagraphTest.php.

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

67 : void
68 {
69 $cases = [
70 '',
71 'xx',
72 'xx [str]xx[/str] xx',
73 'xx [iln cat="106"] xx',
74 'xx [/iln] xx',
75 ];
76
77 foreach ($cases as $case) {
78 $text = ilPCParagraph::_input2xml($case, "en", true, false);
79 $use_internal_errors = libxml_use_internal_errors(true);
80 $sxe = simplexml_load_string("<?xml version='1.0'?><dummy>" . $text . "</dummy>");
81 libxml_use_internal_errors($use_internal_errors);
82 $res = true;
83 if ($sxe === false) {
84 $res = $text;
85 }
86 $this->assertEquals(
87 true,
88 $res
89 );
90 }
91 }

References $res, and ilPCParagraph\_input2xml().

+ Here is the call graph for this function:

◆ testHandleAjaxContentPost()

PCParagraphTest::testHandleAjaxContentPost ( )

Test handleAjaxContentPost.

Definition at line 213 of file PCParagraphTest.php.

213 : void
214 {
215 $cases = [
216 '&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;'
217 => '<SimpleBulletList><SimpleListItem>aa</SimpleListItem><SimpleListItem>bb</SimpleListItem><SimpleListItem>cc</SimpleListItem></SimpleBulletList>'
218 ];
219
220 foreach ($cases as $in => $expected) {
222 $this->assertEquals(
223 $expected,
224 $out
225 );
226 }
227 }
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.

References $out, and ilPCParagraph\handleAjaxContentPost().

+ Here is the call graph for this function:

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