ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PCProfileTest.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 ilPCProfile($page);
30 $this->assertEquals(
31 ilPCProfile::class,
32 get_class($pc)
33 );
34 }
35
36 public function testCreate(): void
37 {
38 $page = $this->getEmptyPageWithDom();
39 $pc = new ilPCProfile($page);
40 $pc->create($page, "pg", "", "MyPlugin", "1.0");
41 $this->assertXmlEquals(
42 '<PageObject HierId="pg"><PageContent><Profile></Profile></PageContent></PageObject>',
43 $page->getXMLFromDom()
44 );
45 }
46
47 public function testFields(): void
48 {
49 $page = $this->getEmptyPageWithDom();
50 $pc = new ilPCProfile($page);
51 $pc->create($page, "pg", "");
52 $pc->setFields(
53 "manual",
54 [
55 "Firstname","Lastname"
56 ]
57 );
58
59 $this->assertEquals(
60 [
61 0 => "Firstname",
62 1 => "Lastname"
63 ],
64 $pc->getFields()
65 );
66
67 $this->assertEquals(
68 "manual",
69 $pc->getMode()
70 );
71
72 $page->stripHierIDs();
73
74 $expected = <<<EOT
75<PageObject><PageContent><Profile Mode="manual" User="0"><ProfileField Name="Firstname"></ProfileField><ProfileField Name="Lastname"></ProfileField></Profile></PageContent></PageObject>
76EOT;
77 $this->assertXmlEquals(
78 $expected,
79 $page->getXMLFromDom()
80 );
81 }
82
83 public function testFieldsAll(): void
84 {
85 $page = $this->getEmptyPageWithDom();
86 $pc = new ilPCProfile($page);
87 $pc->create($page, "pg", "");
88 $pc->setFields(
89 "all"
90 );
91
92 $this->assertEquals(
93 [
94 ],
95 $pc->getFields()
96 );
97
98 $this->assertEquals(
99 "all",
100 $pc->getMode()
101 );
102
103 $page->stripHierIDs();
104
105 $expected = <<<EOT
106<PageObject><PageContent><Profile Mode="all" User="0"></Profile></PageContent></PageObject>
107EOT;
108 $this->assertXmlEquals(
109 $expected,
110 $page->getXMLFromDom()
111 );
112 }
113}
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...