ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PCSectionTest.php
Go to the documentation of this file.
1 <?php
2 
20 
25 {
26  public function testConstruction(): void
27  {
28  $page = $this->getEmptyPageWithDom();
29  $pc_sec = new ilPCSection($page);
30  $this->assertEquals(
31  ilPCSection::class,
32  get_class($pc_sec)
33  );
34  }
35 
36  public function testCreate(): void
37  {
38  $page = $this->getEmptyPageWithDom();
39  $pc_sec = new ilPCSection($page);
40  $pc_sec->create($page, "pg");
41  $this->assertXmlEquals(
42  '<PageObject HierId="pg"><PageContent><Section Characteristic="Block"></Section></PageContent></PageObject>',
43  $page->getXMLFromDom()
44  );
45  }
46 
47  public function testCharacteristic(): void
48  {
49  $page = $this->getEmptyPageWithDom();
50  $pc_sec = new ilPCSection($page);
51  $pc_sec->create($page, "pg");
52  $pc_sec->setCharacteristic("MyChar");
53 
54  $this->assertEquals(
55  "MyChar",
56  $pc_sec->getCharacteristic()
57  );
58 
59  $expected = <<<EOT
60 <PageObject HierId="pg"><PageContent><Section Characteristic="MyChar"></Section></PageContent></PageObject>
61 EOT;
62 
63  $this->assertXmlEquals(
64  $expected,
65  $page->getXMLFromDom()
66  );
67  }
68 
69  public function testProtected(): void
70  {
71  $page = $this->getEmptyPageWithDom();
72  $pc_sec = new ilPCSection($page);
73  $pc_sec->create($page, "pg");
74  $pc_sec->setProtected(true);
75 
76  $this->assertEquals(
77  true,
78  $pc_sec->getProtected()
79  );
80 
81  $expected = <<<EOT
82 <PageObject HierId="pg"><PageContent><Section Characteristic="Block" Protected="1"></Section></PageContent></PageObject>
83 EOT;
84 
85  $this->assertXmlEquals(
86  $expected,
87  $page->getXMLFromDom()
88  );
89  }
90 
91  public function testActiveFrom(): void
92  {
93  $page = $this->getEmptyPageWithDom();
94  $pc_sec = new ilPCSection($page);
95  $pc_sec->create($page, "pg");
96  $pc_sec->setActiveFrom(1234);
97 
98  $this->assertEquals(
99  1234,
100  $pc_sec->getActiveFrom()
101  );
102 
103  $expected = <<<EOT
104 <PageObject HierId="pg"><PageContent><Section Characteristic="Block" ActiveFrom="1234"></Section></PageContent></PageObject>
105 EOT;
106 
107  $this->assertXmlEquals(
108  $expected,
109  $page->getXMLFromDom()
110  );
111  }
112 
113  public function testActiveTo(): void
114  {
115  $page = $this->getEmptyPageWithDom();
116  $pc_sec = new ilPCSection($page);
117  $pc_sec->create($page, "pg");
118  $pc_sec->setActiveTo(5678);
119 
120  $this->assertEquals(
121  5678,
122  $pc_sec->getActiveTo()
123  );
124 
125  $expected = <<<EOT
126 <PageObject HierId="pg"><PageContent><Section Characteristic="Block" ActiveTo="5678"></Section></PageContent></PageObject>
127 EOT;
128 
129  $this->assertXmlEquals(
130  $expected,
131  $page->getXMLFromDom()
132  );
133  }
134 
135  public function testPermission(): void
136  {
137  $page = $this->getEmptyPageWithDom();
138  $pc_sec = new ilPCSection($page);
139  $pc_sec->create($page, "pg");
140  $pc_sec->setPermission("write");
141 
142  $this->assertEquals(
143  "write",
144  $pc_sec->getPermission()
145  );
146 
147  $expected = <<<EOT
148 <PageObject HierId="pg"><PageContent><Section Characteristic="Block" Permission="write"></Section></PageContent></PageObject>
149 EOT;
150 
151  $this->assertXmlEquals(
152  $expected,
153  $page->getXMLFromDom()
154  );
155  }
156 
157  public function testPermissionRefId(): void
158  {
159  $page = $this->getEmptyPageWithDom();
160  $pc_sec = new ilPCSection($page);
161  $pc_sec->create($page, "pg");
162  $pc_sec->setPermissionRefId(10);
163 
164  $this->assertEquals(
165  10,
166  $pc_sec->getPermissionRefId()
167  );
168 
169  $expected = <<<EOT
170 <PageObject HierId="pg"><PageContent><Section Characteristic="Block" PermissionRefId="il__ref_10"></Section></PageContent></PageObject>
171 EOT;
172 
173  $this->assertXmlEquals(
174  $expected,
175  $page->getXMLFromDom()
176  );
177  }
178 
179  public function testExtLink(): void
180  {
181  $page = $this->getEmptyPageWithDom();
182  $pc_sec = new ilPCSection($page);
183  $pc_sec->create($page, "pg");
184  $pc_sec->setExtLink("https://www.ilias.de");
185 
186  $ext_link = $pc_sec->getLink();
187 
188  $this->assertEquals(
189  "ExtLink",
190  $ext_link["LinkType"]
191  );
192 
193  $this->assertEquals(
194  "https://www.ilias.de",
195  $ext_link["Href"]
196  );
197 
198  $expected = <<<EOT
199 <PageObject HierId="pg"><PageContent><Section Characteristic="Block"><ExtLink Href="https://www.ilias.de"></ExtLink></Section></PageContent></PageObject>
200 EOT;
201 
202  $this->assertXmlEquals(
203  $expected,
204  $page->getXMLFromDom()
205  );
206  }
207 
208  public function testIntLink(): void
209  {
210  $page = $this->getEmptyPageWithDom();
211  $pc_sec = new ilPCSection($page);
212  $pc_sec->create($page, "pg");
213  $pc_sec->setIntLink("mytype", "mytarget", "myframe");
214 
215  $link = $pc_sec->getLink();
216 
217  $this->assertEquals(
218  "IntLink",
219  $link["LinkType"]
220  );
221 
222  $this->assertEquals(
223  "mytype",
224  $link["Type"]
225  );
226 
227  $this->assertEquals(
228  "mytarget",
229  $link["Target"]
230  );
231 
232  $this->assertEquals(
233  "myframe",
234  $link["TargetFrame"]
235  );
236 
237  $expected = <<<EOT
238 <PageObject HierId="pg"><PageContent><Section Characteristic="Block"><IntLink Type="mytype" Target="mytarget" TargetFrame="myframe"></IntLink></Section></PageContent></PageObject>
239 EOT;
240 
241  $this->assertXmlEquals(
242  $expected,
243  $page->getXMLFromDom()
244  );
245  }
246 
247  public function testNoLink(): void
248  {
249  $page = $this->getEmptyPageWithDom();
250  $pc_sec = new ilPCSection($page);
251  $pc_sec->create($page, "pg");
252 
253  $link = $pc_sec->getLink();
254 
255  $this->assertEquals(
256  "NoLink",
257  $link["LinkType"]
258  );
259 
260  $pc_sec->setIntLink("mytype", "mytarget", "myframe");
261  $pc_sec->setNoLink();
262 
263  $link = $pc_sec->getLink();
264 
265  $this->assertEquals(
266  "NoLink",
267  $link["LinkType"]
268  );
269 
270  $expected = <<<EOT
271 <PageObject HierId="pg"><PageContent><Section Characteristic="Block"></Section></PageContent></PageObject>
272 EOT;
273 
274  $this->assertXmlEquals(
275  $expected,
276  $page->getXMLFromDom()
277  );
278  }
279 
280  public function testModel(): void
281  {
282  $page = $this->getEmptyPageWithDom();
283  $pc_sec = new ilPCSection($page);
284  $pc_sec->create($page, "pg");
285 
286  $pc_sec->setProtected(true);
287 
288  $model = new stdClass();
289  $model->protected = true;
290 
291 
292  $this->assertEquals(
293  $model,
294  $pc_sec->getModel()
295  );
296  }
297 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)