ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PCContentIncludeTest.php
Go to the documentation of this file.
1<?php
2
19use PHPUnit\Framework\TestCase;
20
25{
26 public function testConstruction(): void
27 {
28 $page = $this->getEmptyPageWithDom();
29 $pc = new ilPCContentInclude($page);
30 $this->assertEquals(
31 ilPCContentInclude::class,
32 get_class($pc)
33 );
34 }
35
36 public function testCreate(): void
37 {
38 $page = $this->getEmptyPageWithDom();
39 $pc = new ilPCContentInclude($page);
40 $pc->create($page, "pg");
41 $this->assertXmlEquals(
42 '<PageObject HierId="pg"><PageContent><ContentInclude></ContentInclude></PageContent></PageObject>',
43 $page->getXMLFromDom()
44 );
45 }
46
47 public function testContentId(): void
48 {
49 $page = $this->getEmptyPageWithDom();
50 $pc = new ilPCContentInclude($page);
51 $pc->create($page, "pg");
52 $pc->setContentId("10");
53
54 $this->assertEquals(
55 "10",
56 $pc->getContentId()
57 );
58
59 $expected = <<<EOT
60<PageObject HierId="pg"><PageContent><ContentInclude ContentId="10"></ContentInclude></PageContent></PageObject>
61EOT;
62
63 $this->assertXmlEquals(
64 $expected,
65 $page->getXMLFromDom()
66 );
67 }
68
69 public function testContentType(): void
70 {
71 $page = $this->getEmptyPageWithDom();
72 $pc = new ilPCContentInclude($page);
73 $pc->create($page, "pg");
74 $pc->setContentType("type");
75
76 $this->assertEquals(
77 "type",
78 $pc->getContentType()
79 );
80
81 $expected = <<<EOT
82<PageObject HierId="pg"><PageContent><ContentInclude ContentType="type"></ContentInclude></PageContent></PageObject>
83EOT;
84
85 $this->assertXmlEquals(
86 $expected,
87 $page->getXMLFromDom()
88 );
89 }
90
91 public function testInstId(): void
92 {
93 $page = $this->getEmptyPageWithDom();
94 $pc = new ilPCContentInclude($page);
95 $pc->create($page, "pg");
96 $pc->setInstId("123");
97
98 $this->assertEquals(
99 "123",
100 $pc->getInstId()
101 );
102
103 $expected = <<<EOT
104<PageObject HierId="pg"><PageContent><ContentInclude InstId="123"></ContentInclude></PageContent></PageObject>
105EOT;
106
107 $this->assertXmlEquals(
108 $expected,
109 $page->getXMLFromDom()
110 );
111 }
112
113 public function testCollectContentIncludes(): void
114 {
115 $page = $this->getEmptyPageWithDom();
116 $pc = new ilPCContentInclude($page);
117 $pc->create($page, "pg");
118 $pc->setInstId("123");
119 $pc->setContentType("type");
120 $pc->setContentId(55);
121
122 $includes = ilPCContentInclude::collectContentIncludes($page, $page->getDomDoc());
123
124 $this->assertEquals(
125 ['type:55:123' => [
126 "type" => "type",
127 "id" => "55",
128 "inst_id" => "123"
129 ]],
130 $includes
131 );
132 }
133}
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
Class ilPCContentInclude.
static collectContentIncludes(ilPageObject $a_page, DOMDocument $a_domdoc)
get all content includes that are used within the page