ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest Class Reference
+ Inheritance diagram for PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest:
+ Collaboration diagram for PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest:

Public Member Functions

 testGetContentDomNodePg ()
 
 testGetContentDomNodePCId ()
 
 testGetContentDomNodeHierId ()
 
 testDeleteContent ()
 
 testDeleteContents ()
 
 testSwitchEnableMultiple ()
 
 testInitialOpenedContent ()
 
 testInitialOpenedContent2 ()
 
 testInitialOpenedContent3 ()
 
 testInsertInstIntoIDsIntLink ()
 
 testInsertInstIntoIDsFileItem ()
 
 testInsertInstIntoIDsQuestion ()
 
 testInsertInstIntoIDsContentInclude ()
 

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 29 of file PageContentManagerTest.php.

Member Function Documentation

◆ testDeleteContent()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testDeleteContent ( )

Definition at line 96 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\insertParagraphAt().

96  : void
97  {
98  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
99  $page = $this->getEmptyPageWithDom();
100  $page_content = new PageContentManager($page->getDomDoc());
101 
102  $this->insertParagraphAt($page, "pg", "Hello");
103  $this->insertParagraphAt($page, "1", "World");
104  $page->insertPCIds();
105 
106  $page_content->deleteContent($page, "1");
107 
108  $expected = <<<EOT
109 <PageObject HierId="pg"><PageContent HierId="2" PCID="00000000000000000000000000000002"><Paragraph Language="en">World</Paragraph></PageContent></PageObject>
110 EOT;
111  $this->assertXmlEquals(
112  $expected,
113  $page->getXMLFromDom()
114  );
115  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testDeleteContents()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testDeleteContents ( )

Definition at line 117 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\insertParagraphAt().

117  : void
118  {
119  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
120  $page = $this->getEmptyPageWithDom();
121  $page_content = new PageContentManager($page->getDomDoc());
122 
123  $this->insertParagraphAt($page, "pg", "Hello");
124  $this->insertParagraphAt($page, "1", "little");
125  $this->insertParagraphAt($page, "2", "World");
126  $page->insertPCIds();
127 
128  $page_content->deleteContents($page, ["1", "2"]);
129 
130  $expected = <<<EOT
131 <PageObject HierId="pg"><PageContent HierId="3" PCID="00000000000000000000000000000003"><Paragraph Language="en">World</Paragraph></PageContent></PageObject>
132 EOT;
133  $this->assertXmlEquals(
134  $expected,
135  $page->getXMLFromDom()
136  );
137  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testGetContentDomNodeHierId()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testGetContentDomNodeHierId ( )

Definition at line 75 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\insertParagraphAt().

75  : void
76  {
77  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
78  $page = $this->getEmptyPageWithDom();
79  $page_content = new PageContentManager($page->getDomDoc());
80 
81  $this->insertParagraphAt($page, "pg", "Hello");
82  $this->insertParagraphAt($page, "1", "World");
83  $page->insertPCIds();
84 
85  $node = $page_content->getContentDomNode("1");
86 
87  $expected = <<<EOT
88 <PageContent HierId="1" PCID="00000000000000000000000000000001"><Paragraph Language="en">Hello</Paragraph></PageContent>
89 EOT;
90  $this->assertXmlEquals(
91  $expected,
92  $dom_util->dump($node)
93  );
94  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testGetContentDomNodePCId()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testGetContentDomNodePCId ( )

Definition at line 53 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\insertParagraphAt().

53  : void
54  {
55  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
56  $page = $this->getEmptyPageWithDom();
57  $page_content = new PageContentManager($page->getDomDoc());
58 
59  $this->insertParagraphAt($page, "pg", "Hello");
60  $this->insertParagraphAt($page, "1", "World");
61  $page->insertPCIds();
62 
63  $node = $page_content->getContentDomNode("", "00000000000000000000000000000002");
64 
65  $expected = <<<EOT
66 <PageContent HierId="2" PCID="00000000000000000000000000000002"><Paragraph Language="en">World</Paragraph></PageContent>
67 EOT;
68 
69  $this->assertXmlEquals(
70  $expected,
71  $dom_util->dump($node)
72  );
73  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testGetContentDomNodePg()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testGetContentDomNodePg ( )

Definition at line 31 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\insertParagraphAt().

31  : void
32  {
33  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
34  $page = $this->getEmptyPageWithDom();
35  $page_content = new PageContentManager($page->getDomDoc());
36 
37  $this->insertParagraphAt($page, "pg", "Hello");
38  $this->insertParagraphAt($page, "1", "World");
39  $page->insertPCIds();
40 
41  $node = $page_content->getContentDomNode("pg");
42 
43  $expected = <<<EOT
44 <PageObject HierId="pg"><PageContent HierId="1" PCID="00000000000000000000000000000001"><Paragraph Language="en">Hello</Paragraph></PageContent><PageContent HierId="2" PCID="00000000000000000000000000000002"><Paragraph Language="en">World</Paragraph></PageContent></PageObject>
45 EOT;
46 
47  $this->assertXmlEquals(
48  $expected,
49  $dom_util->dump($node)
50  );
51  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testInitialOpenedContent()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInitialOpenedContent ( )

Definition at line 164 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\getPCDefinition(), and COPageTestBase\insertParagraphAt().

164  : void
165  {
166  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
167  $page = $this->getEmptyPageWithDom();
168  $page_content = new PageContentManager(
169  $page->getDomDoc(),
170  $this->getPCDefinition()
171  );
172 
173  $this->insertParagraphAt($page, "pg", "Hello");
174  $page->insertPCIds();
175 
176  $page_content->setInitialOpenedContent(
177  "media",
178  5,
179  ""
180  );
181 
182  $expected = [
183  "id" => 5,
184  "type" => "media",
185  "target" => ""
186  ];
187 
188  $this->assertEquals(
189  $expected,
190  $page_content->getInitialOpenedContent()
191  );
192 
193  $expected = <<<EOT
194 <PageObject HierId="pg"><PageContent HierId="1" PCID="00000000000000000000000000000001"><Paragraph Language="en">Hello</Paragraph></PageContent><InitOpenedContent><IntLink Target="il__mob_5" Type="MediaObject" TargetFrame=""/></InitOpenedContent></PageObject>
195 EOT;
196  $this->assertXmlEquals(
197  $expected,
198  $page->getXMLFromDom()
199  );
200  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testInitialOpenedContent2()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInitialOpenedContent2 ( )

Definition at line 202 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\getPCDefinition(), and COPageTestBase\insertParagraphAt().

202  : void
203  {
204  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
205  $page = $this->getEmptyPageWithDom();
206  $page_content = new PageContentManager(
207  $page->getDomDoc(),
208  $this->getPCDefinition()
209  );
210 
211  $this->insertParagraphAt($page, "pg", "Hello");
212  $page->insertPCIds();
213 
214  $page_content->setInitialOpenedContent(
215  "media",
216  5,
217  ""
218  );
219 
220  $page_content->setInitialOpenedContent(
221  "term",
222  10,
223  "Glossary"
224  );
225 
226  $expected = [
227  "id" => 10,
228  "type" => "term",
229  "target" => "Glossary"
230  ];
231 
232  $this->assertEquals(
233  $expected,
234  $page_content->getInitialOpenedContent()
235  );
236 
237  $expected = <<<EOT
238 <PageObject HierId="pg"><PageContent HierId="1" PCID="00000000000000000000000000000001"><Paragraph Language="en">Hello</Paragraph></PageContent><InitOpenedContent><IntLink Target="il__git_10" Type="GlossaryItem" TargetFrame="Glossary"/></InitOpenedContent></PageObject>
239 EOT;
240  $this->assertXmlEquals(
241  $expected,
242  $page->getXMLFromDom()
243  );
244  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testInitialOpenedContent3()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInitialOpenedContent3 ( )

Definition at line 246 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\getPCDefinition(), and COPageTestBase\insertParagraphAt().

246  : void
247  {
248  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
249  $page = $this->getEmptyPageWithDom();
250  $page_content = new PageContentManager(
251  $page->getDomDoc(),
252  $this->getPCDefinition()
253  );
254 
255  $this->insertParagraphAt($page, "pg", "Hello");
256  $page->insertPCIds();
257 
258  $page_content->setInitialOpenedContent(
259  "media",
260  5,
261  ""
262  );
263 
264  $page_content->setInitialOpenedContent();
265 
266  $expected = [];
267 
268  $this->assertEquals(
269  $expected,
270  $page_content->getInitialOpenedContent()
271  );
272 
273  $expected = <<<EOT
274 <PageObject HierId="pg"><PageContent HierId="1" PCID="00000000000000000000000000000001"><Paragraph Language="en">Hello</Paragraph></PageContent></PageObject>
275 EOT;
276  $this->assertXmlEquals(
277  $expected,
278  $page->getXMLFromDom()
279  );
280  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

◆ testInsertInstIntoIDsContentInclude()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInsertInstIntoIDsContentInclude ( )

Definition at line 348 of file PageContentManagerTest.php.

References COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\getPCDefinition().

348  : void
349  {
350  $page = $this->getEmptyPageWithDom();
351  $page_content = new PageContentManager(
352  $page->getDomDoc(),
353  $this->getPCDefinition()
354  );
355 
356  $pc = new \ilPCContentInclude($page);
357  $pc->create($page, "pg");
358  $pc->setContentId(13);
359  $page_content->insertInstIntoIDs("8877");
360 
361  $this->assertStringContainsString(
362  '<ContentInclude ContentId="13" InstId="8877"/>',
363  $page->getXMLFromDom()
364  );
365  }
+ Here is the call graph for this function:

◆ testInsertInstIntoIDsFileItem()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInsertInstIntoIDsFileItem ( )

Definition at line 308 of file PageContentManagerTest.php.

References COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\getPCDefinition().

308  : void
309  {
310  $page = $this->getEmptyPageWithDom();
311  $page_content = new PageContentManager(
312  $page->getDomDoc(),
313  $this->getPCDefinition()
314  );
315 
316  $pc = new \ilPCFileList($page);
317  $pc->create($page, "pg");
318  $pc->appendItem(10, "file_loc", "image/jpeg");
319  $page->insertPCIds();
320 
321  $page_content->insertInstIntoIDs("8877");
322 
323  $this->assertStringContainsString(
324  '<Identifier Catalog="ILIAS" Entry="il_8877_file_10"/>',
325  $page->getXMLFromDom()
326  );
327  }
+ Here is the call graph for this function:

◆ testInsertInstIntoIDsIntLink()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInsertInstIntoIDsIntLink ( )

Definition at line 282 of file PageContentManagerTest.php.

References COPageTestBase\getEmptyPageWithDom(), COPageTestBase\getPCDefinition(), COPageTestBase\insertParagraphAt(), and COPageTestBase\legacyHtmlToXml().

282  : void
283  {
284  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
285  $page = $this->getEmptyPageWithDom();
286  $page_content = new PageContentManager(
287  $page->getDomDoc(),
288  $this->getPCDefinition()
289  );
290 
291  $xml = $this->legacyHtmlToXml(
292  '<div id="1:1234" class="ilc_text_block_Standard">' .
293  '[iln page="107"] xx [/iln]' .
294  '</div>'
295  );
296 
297  $this->insertParagraphAt($page, "pg", $xml);
298  $page->insertPCIds();
299 
300  $page_content->insertInstIntoIDs("8877");
301 
302  $this->assertStringContainsString(
303  '<IntLink Target="il_8877_pg_107" Type="PageObject">',
304  $page->getXMLFromDom()
305  );
306  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
legacyHtmlToXml(string $content)
+ Here is the call graph for this function:

◆ testInsertInstIntoIDsQuestion()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testInsertInstIntoIDsQuestion ( )

Definition at line 329 of file PageContentManagerTest.php.

References COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\getPCDefinition().

329  : void
330  {
331  $page = $this->getEmptyPageWithDom();
332  $page_content = new PageContentManager(
333  $page->getDomDoc(),
334  $this->getPCDefinition()
335  );
336 
337  $pc = new \ilPCQuestion($page);
338  $pc->create($page, "pg", "");
339  $pc->setQuestionReference("il__qst_13");
340  $page_content->insertInstIntoIDs("8877");
341 
342  $this->assertStringContainsString(
343  '<Question QRef="il_8877_qst_13"/>',
344  $page->getXMLFromDom()
345  );
346  }
+ Here is the call graph for this function:

◆ testSwitchEnableMultiple()

PHPUnit\Framework\Attributes\Test\Page\PageContentManagerTest::testSwitchEnableMultiple ( )

Definition at line 139 of file PageContentManagerTest.php.

References COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\getPCDefinition(), and COPageTestBase\insertParagraphAt().

139  : void
140  {
141  $dom_util = new \ILIAS\COPage\Dom\DomUtil();
142  $page = $this->getEmptyPageWithDom();
143  $page_content = new PageContentManager(
144  $page->getDomDoc(),
145  $this->getPCDefinition()
146  );
147 
148  $this->insertParagraphAt($page, "pg", "Hello");
149  $this->insertParagraphAt($page, "1", "little");
150  $this->insertParagraphAt($page, "2", "World");
151  $page->insertPCIds();
152 
153  $page_content->switchEnableMultiple($page, ["1", "2"]);
154 
155  $expected = <<<EOT
156 <PageObject HierId="pg"><PageContent HierId="1" PCID="00000000000000000000000000000001" Enabled="False"><Paragraph Language="en">Hello</Paragraph></PageContent><PageContent HierId="2" PCID="00000000000000000000000000000002" Enabled="False"><Paragraph Language="en">little</Paragraph></PageContent><PageContent HierId="3" PCID="00000000000000000000000000000003"><Paragraph Language="en">World</Paragraph></PageContent></PageObject>
157 EOT;
158  $this->assertXmlEquals(
159  $expected,
160  $page->getXMLFromDom()
161  );
162  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

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