ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PCDataTableTest Class Reference
+ Inheritance diagram for PCDataTableTest:
+ Collaboration diagram for PCDataTableTest:

Public Member Functions

 testConstruction ()
 
 testCreate ()
 
 testData ()
 
 testEmptyCell ()
 
 testCellText ()
 
 testAddRows ()
 
 testImportSpreadsheet ()
 
 testLanguage ()
 
 testWidth ()
 
 testAlign ()
 
 testTDWidth ()
 
 testSpans ()
 
 testCellHidden ()
 
 testTDClass ()
 
 testTDAlignment ()
 
 testCaption ()
 
 testFirstRowStyle ()
 
 testClass ()
 
 testTemplate ()
 
 testHeaderRows ()
 
 testFooterRows ()
 
 testHeaderCols ()
 
 testFooterCols ()
 
 testModel ()
 

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 PCDataTableTest.php.

Member Function Documentation

◆ testAddRows()

PCDataTableTest::testAddRows ( )

Definition at line 151 of file PCDataTableTest.php.

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

151  : void
152  {
153  $page = $this->getEmptyPageWithDom();
154  $pc = new ilPCDataTable($page);
155  $pc->create($page, "pg");
156  $pc->setLanguage("en");
157  $pc->addRows(1, 2);
158  $page->validateDom();
159 
160  $expected = <<<EOT
161 <PageObject><PageContent><Table Language="en" DataTable="y"><TableRow><TableData></TableData><TableData></TableData></TableRow></Table></PageContent></PageObject>
162 EOT;
163 
164  $this->assertXmlEquals(
165  $expected,
166  $page->getXMLFromDom()
167  );
168  }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testAlign()

PCDataTableTest::testAlign ( )

Definition at line 218 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

218  : void
219  {
220  $page = $this->getEmptyPageWithDom();
221  $pc = new ilPCDataTable($page);
222  $pc->create($page, "pg");
223  $pc->setLanguage("en");
224  $pc->addRows(1, 1);
225  $page->validateDom();
226  $pc->setHorizontalAlign("Right");
227  $this->assertEquals(
228  "Right",
229  $pc->getHorizontalAlign()
230  );
231  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testCaption()

PCDataTableTest::testCaption ( )

Definition at line 351 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

351  : void
352  {
353  $page = $this->getEmptyPageWithDom();
354  $pc = new ilPCDataTable($page);
355  $pc->create($page, "pg");
356  $pc->setLanguage("en");
357  $pc->addRows(1, 1);
358  $page->addHierIDs();
359  $pc->setHierId("1");
360  $pc->setCaption("Moin", "Top");
361  $this->assertEquals(
362  "Moin",
363  $pc->getCaption()
364  );
365  $this->assertEquals(
366  "Top",
367  $pc->getCaptionAlign()
368  );
369  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testCellHidden()

PCDataTableTest::testCellHidden ( )

Definition at line 283 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

283  : void
284  {
285  $page = $this->getEmptyPageWithDom();
286  $pc = new ilPCDataTable($page);
287  $pc->create($page, "pg");
288  $colspans = [
289  0 => [0 => 2, 1 => 1]
290  ];
291  $rowspans = [
292  0 => [0 => 1, 1 => 1]
293  ];
294  $h1 = $pc->checkCellHidden(
295  $colspans,
296  $rowspans,
297  0,
298  0,
299  );
300  $h2 = $pc->checkCellHidden(
301  $colspans,
302  $rowspans,
303  1,
304  0,
305  );
306 
307  $this->assertEquals(
308  false,
309  $h1
310  );
311  $this->assertEquals(
312  true,
313  $h2
314  );
315  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testCellText()

PCDataTableTest::testCellText ( )

Definition at line 131 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

131  : void
132  {
133  $page = $this->getEmptyPageWithDom();
134  $pc = new ilPCDataTable($page);
135  $pc->create($page, "pg");
136  $pc->setLanguage("en");
137  $row1 = $pc->addRow();
138  $pc->addCell($row1, "one", "en");
139  $page->addHierIDs();
140  $pc->setHierId("1");
141 
142  // note: this gives us the paragraph node in the cell
143  $text = $pc->getCellText(0, 0);
144 
145  $this->assertEquals(
146  "one",
147  $text
148  );
149  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testClass()

PCDataTableTest::testClass ( )

Definition at line 391 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

391  : void
392  {
393  $page = $this->getEmptyPageWithDom();
394  $pc = new ilPCDataTable($page);
395  $pc->create($page, "pg");
396  $pc->setLanguage("en");
397  $pc->addRows(1, 1);
398  $page->addHierIDs();
399  $pc->setHierId("1");
400  $pc->setClass("MyClass");
401  $this->assertEquals(
402  "MyClass",
403  $pc->getClass()
404  );
405  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testConstruction()

PCDataTableTest::testConstruction ( )

Definition at line 26 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

26  : void
27  {
28  $page = $this->getEmptyPageWithDom();
29  $pc = new ilPCDataTable($page);
30  $this->assertEquals(
31  ilPCDataTable::class,
32  get_class($pc)
33  );
34  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testCreate()

PCDataTableTest::testCreate ( )

Definition at line 36 of file PCDataTableTest.php.

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

36  : void
37  {
38  $page = $this->getEmptyPageWithDom();
39  $pc = new ilPCDataTable($page);
40  $pc->create($page, "pg");
41  $this->assertXmlEquals(
42  '<PageObject HierId="pg"><PageContent><Table Language="" DataTable="y"></Table></PageContent></PageObject>',
43  $page->getXMLFromDom()
44  );
45  }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testData()

PCDataTableTest::testData ( )

Definition at line 47 of file PCDataTableTest.php.

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

47  : void
48  {
49  $page = $this->getEmptyPageWithDom();
50  $pc = new ilPCDataTable($page);
51  $pc->create($page, "pg");
52  $row1 = $pc->addRow();
53  $pc->addCell($row1, "one", "en");
54  $pc->addCell($row1, "two", "en");
55  $row2 = $pc->addRow();
56  $pc->addCell($row2, "three", "en");
57  $pc->addCell($row2, "four", "en");
58 
59  $expected = <<<EOT
60 <PageObject HierId="pg"><PageContent><Table Language="" DataTable="y">
61 <TableRow>
62 <TableData>
63 <PageContent><Paragraph Language="en" Characteristic="TableContent">one</Paragraph></PageContent>
64 </TableData>
65 <TableData>
66 <PageContent><Paragraph Language="en" Characteristic="TableContent">two</Paragraph></PageContent>
67 </TableData></TableRow>
68 <TableRow><TableData>
69 <PageContent><Paragraph Language="en" Characteristic="TableContent">three</Paragraph></PageContent>
70 </TableData>
71 <TableData>
72 <PageContent><Paragraph Language="en" Characteristic="TableContent">four</Paragraph></PageContent>
73 </TableData></TableRow></Table></PageContent></PageObject>
74 EOT;
75 
76  $this->assertXmlEquals(
77  $expected,
78  $page->getXMLFromDom()
79  );
80 
81  $page->addHierIDs();
82  $pc->setHierId("1");
83 
84  $pc->setData([
85  ["five", "six"],
86  ["seven", "eight"]
87  ]);
88 
89  $expected = <<<EOT
90 <PageObject HierId="pg"><PageContent HierId="1"><Table Language="" DataTable="y"><TableRow HierId="1_1"><TableData HierId="1_1_1"><PageContent HierId="1_1_1_1"><Paragraph Language="en" Characteristic="TableContent">five</Paragraph></PageContent></TableData><TableData HierId="1_1_2"><PageContent HierId="1_1_2_1"><Paragraph Language="en" Characteristic="TableContent">six</Paragraph></PageContent></TableData></TableRow><TableRow HierId="1_2"><TableData HierId="1_2_1"><PageContent HierId="1_2_1_1"><Paragraph Language="en" Characteristic="TableContent">seven</Paragraph></PageContent></TableData><TableData HierId="1_2_2"><PageContent HierId="1_2_2_1"><Paragraph Language="en" Characteristic="TableContent">eight</Paragraph></PageContent></TableData></TableRow></Table></PageContent></PageObject>
91 EOT;
92 
93  $this->assertXmlEquals(
94  $expected,
95  $page->getXMLFromDom()
96  );
97  }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testEmptyCell()

PCDataTableTest::testEmptyCell ( )

Definition at line 99 of file PCDataTableTest.php.

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

99  : void
100  {
101  $page = $this->getEmptyPageWithDom();
102  $pc = new ilPCDataTable($page);
103  $pc->create($page, "pg");
104  $pc->setLanguage("en");
105  $row1 = $pc->addRow();
106  $pc->addCell($row1, "one", "en");
107  $page->addHierIDs();
108  $pc->setHierId("1");
109  // note: this gives us the paragraph node in the cell
110  $cell = $pc->getCellNode(0, 0);
111  $pc->makeEmptyCell($cell->parentNode->parentNode);
112  $page->stripHierIDs();
113  $page->validateDom();
114 
115  $expected = <<<EOT
116 <PageObject><PageContent><Table Language="en" DataTable="y">
117 <TableRow>
118 <TableData>
119 <PageContent><Paragraph Characteristic="TableContent" Language="en"></Paragraph></PageContent>
120 </TableData>
121 </TableRow>
122 </Table></PageContent></PageObject>
123 EOT;
124 
125  $this->assertXmlEquals(
126  $expected,
127  $page->getXMLFromDom()
128  );
129  }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testFirstRowStyle()

PCDataTableTest::testFirstRowStyle ( )

Definition at line 371 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

371  : void
372  {
373  $page = $this->getEmptyPageWithDom();
374  $pc = new ilPCDataTable($page);
375  $pc->create($page, "pg");
376  $pc->setLanguage("en");
377  $pc->addRows(2, 2);
378  $page->addHierIDs();
379  $pc->setFirstRowStyle("MyClass");
380  $this->assertEquals(
381  [
382  '1_1_1:' => 'MyClass',
383  '1_1_2:' => 'MyClass',
384  '1_2_1:' => '',
385  '1_2_2:' => ''
386  ],
387  $pc->getAllCellClasses()
388  );
389  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testFooterCols()

PCDataTableTest::testFooterCols ( )

Definition at line 459 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

459  : void
460  {
461  $page = $this->getEmptyPageWithDom();
462  $pc = new ilPCDataTable($page);
463  $pc->create($page, "pg");
464  $pc->setFooterCols(2);
465  $this->assertEquals(
466  2,
467  $pc->getFooterCols()
468  );
469  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testFooterRows()

PCDataTableTest::testFooterRows ( )

Definition at line 435 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

435  : void
436  {
437  $page = $this->getEmptyPageWithDom();
438  $pc = new ilPCDataTable($page);
439  $pc->create($page, "pg");
440  $pc->setFooterRows(2);
441  $this->assertEquals(
442  2,
443  $pc->getFooterRows()
444  );
445  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testHeaderCols()

PCDataTableTest::testHeaderCols ( )

Definition at line 447 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

447  : void
448  {
449  $page = $this->getEmptyPageWithDom();
450  $pc = new ilPCDataTable($page);
451  $pc->create($page, "pg");
452  $pc->setHeaderCols(2);
453  $this->assertEquals(
454  2,
455  $pc->getHeaderCols()
456  );
457  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testHeaderRows()

PCDataTableTest::testHeaderRows ( )

Definition at line 423 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

423  : void
424  {
425  $page = $this->getEmptyPageWithDom();
426  $pc = new ilPCDataTable($page);
427  $pc->create($page, "pg");
428  $pc->setHeaderRows(2);
429  $this->assertEquals(
430  2,
431  $pc->getHeaderRows()
432  );
433  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testImportSpreadsheet()

PCDataTableTest::testImportSpreadsheet ( )

Definition at line 170 of file PCDataTableTest.php.

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

170  : void
171  {
172  $page = $this->getEmptyPageWithDom();
173  $pc = new ilPCDataTable($page);
174  $pc->create($page, "pg");
175  $pc->setLanguage("en");
176  $pc->importSpreadsheet("en", "one\ttwo\nthree\tfour");
177  $page->validateDom();
178 
179  $expected = <<<EOT
180 <PageObject><PageContent><Table Language="en" DataTable="y"><TableRow><TableData><PageContent><Paragraph Language="en" Characteristic="TableContent">one</Paragraph></PageContent></TableData><TableData><PageContent><Paragraph Language="en" Characteristic="TableContent">two</Paragraph></PageContent></TableData></TableRow><TableRow><TableData><PageContent><Paragraph Language="en" Characteristic="TableContent">three</Paragraph></PageContent></TableData><TableData><PageContent><Paragraph Language="en" Characteristic="TableContent">four</Paragraph></PageContent></TableData></TableRow></Table></PageContent></PageObject>
181 EOT;
182 
183  $this->assertXmlEquals(
184  $expected,
185  $page->getXMLFromDom()
186  );
187  }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testLanguage()

PCDataTableTest::testLanguage ( )

Definition at line 189 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

189  : void
190  {
191  $page = $this->getEmptyPageWithDom();
192  $pc = new ilPCDataTable($page);
193  $pc->create($page, "pg");
194  $pc->setLanguage("fr");
195  $pc->addRows(1, 1);
196  $page->validateDom();
197  $this->assertEquals(
198  "fr",
199  $pc->getLanguage()
200  );
201  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testModel()

PCDataTableTest::testModel ( )

Definition at line 471 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

471  : void
472  {
473  $page = $this->getEmptyPageWithDom();
474  $pc = new ilPCDataTable($page);
475  $pc->create($page, "pg");
476  $pc->setLanguage("en");
477  $pc->importSpreadsheet("en", "one\ttwo\nthree\tfour");
478  $page->addHierIDs();
479  $pc->setHierId("1");
480  //$page->validateDom();
481 
482  $expected = new \stdClass();
483  $expected->content = [
484  0 => [
485  0 => "one",
486  1 => "two"
487  ],
488  1 => [
489  0 => "three",
490  1 => "four"
491  ]
492  ];
493  $expected->characteristic = '';
494  $expected->template = '';
495  $expected->hasHeaderRows = false;
496 
497  $this->assertEquals(
498  $expected,
499  $pc->getModel()
500  );
501  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testSpans()

PCDataTableTest::testSpans ( )

Definition at line 250 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

250  : void
251  {
252  $page = $this->getEmptyPageWithDom();
253  $pc = new ilPCDataTable($page);
254  $pc->create($page, "pg");
255  $pc->setLanguage("en");
256  $pc->addRows(1, 2);
257  $page->addHierIDs();
258  $pc->setTdSpans(
259  ["1_1_1:" => "2", "1_1_2:" => "1"],
260  ["1_1_1:" => "1", "1_1_2:" => "1"],
261  );
262 
263  $spans = $pc->getAllCellSpans();
264 
265  $this->assertEquals(
266  "2",
267  $spans["1_1_1:"]["colspan"]
268  );
269  $this->assertEquals(
270  "",
271  $spans["1_1_1:"]["rowspan"]
272  );
273  $this->assertEquals(
274  "",
275  $spans["1_1_2:"]["colspan"]
276  );
277  $this->assertEquals(
278  "",
279  $spans["1_1_2:"]["rowspan"]
280  );
281  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testTDAlignment()

PCDataTableTest::testTDAlignment ( )

Definition at line 334 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

334  : void
335  {
336  $page = $this->getEmptyPageWithDom();
337  $pc = new ilPCDataTable($page);
338  $pc->create($page, "pg");
339  $pc->setLanguage("en");
340  $pc->addRows(1, 1);
341  $page->addHierIDs();
342  $pc->setTDAlignment("1_1_1", "Right");
343  $this->assertEquals(
344  [
345  "1_1_1:" => "Right"
346  ],
347  $pc->getAllCellAlignments()
348  );
349  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testTDClass()

PCDataTableTest::testTDClass ( )

Definition at line 317 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

317  : void
318  {
319  $page = $this->getEmptyPageWithDom();
320  $pc = new ilPCDataTable($page);
321  $pc->create($page, "pg");
322  $pc->setLanguage("en");
323  $pc->addRows(1, 1);
324  $page->addHierIDs();
325  $pc->setTDClass("1_1_1", "MyClass");
326  $this->assertEquals(
327  [
328  "1_1_1:" => "MyClass"
329  ],
330  $pc->getAllCellClasses()
331  );
332  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testTDWidth()

PCDataTableTest::testTDWidth ( )

Definition at line 233 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

233  : void
234  {
235  $page = $this->getEmptyPageWithDom();
236  $pc = new ilPCDataTable($page);
237  $pc->create($page, "pg");
238  $pc->setLanguage("en");
239  $pc->addRows(1, 1);
240  $page->addHierIDs();
241  $pc->setTDWidth("1_1_1", "33");
242  $this->assertEquals(
243  [
244  "1_1_1:" => "33"
245  ],
246  $pc->getAllCellWidths()
247  );
248  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testTemplate()

PCDataTableTest::testTemplate ( )

Definition at line 407 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

407  : void
408  {
409  $page = $this->getEmptyPageWithDom();
410  $pc = new ilPCDataTable($page);
411  $pc->create($page, "pg");
412  $pc->setLanguage("en");
413  $pc->addRows(1, 1);
414  $page->addHierIDs();
415  $pc->setHierId("1");
416  $pc->setTemplate("MyTemplate");
417  $this->assertEquals(
418  "MyTemplate",
419  $pc->getTemplate()
420  );
421  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ testWidth()

PCDataTableTest::testWidth ( )

Definition at line 203 of file PCDataTableTest.php.

References COPageTestBase\getEmptyPageWithDom().

203  : void
204  {
205  $page = $this->getEmptyPageWithDom();
206  $pc = new ilPCDataTable($page);
207  $pc->create($page, "pg");
208  $pc->setLanguage("en");
209  $pc->addRows(1, 1);
210  $page->validateDom();
211  $pc->setWidth("200");
212  $this->assertEquals(
213  "200",
214  $pc->getWidth()
215  );
216  }
Class ilPCDataTable.
+ Here is the call graph for this function:

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