ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ComponentEntryTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once("vendor/composer/vendor/autoload.php");
22
26
27use PHPUnit\Framework\TestCase;
28
29class ComponentEntryTest extends TestCase
30{
31 protected Entry $entry;
32 protected array $entry_data;
33
34 protected function setUp(): void
35 {
36 $this->entry_data = include "components/ILIAS/UI/tests/Crawler/Fixture/EntryFixture.php";
37 $this->entry = new Entry($this->entry_data);
38 }
39
40
41 public function testConstruct(): void
42 {
43 $this->assertInstanceOf(Entry::class, $this->entry);
44 }
45
46 public function testGetId(): void
47 {
48 $this->assertEquals($this->entry_data["id"], $this->entry->getId());
49 $this->entry->setId("newId");
50 $this->assertEquals("newId", $this->entry->getId());
51 }
52
53 public function testGetTitle(): void
54 {
55 $this->assertEquals($this->entry_data["title"], $this->entry->getTitle());
56 $this->entry->setTitle("newTitle");
57 $this->assertEquals("newTitle", $this->entry->getTitle());
58 }
59
60 public function testIsAbstract(): void
61 {
62 $this->assertEquals($this->entry_data["abstract"], $this->entry->isAbstract());
63 $this->entry->setIsAbstract(false);
64 $this->assertEquals(false, $this->entry->isAbstract());
65 }
66
67 public function testStatusEntry(): void
68 {
69 $this->assertEquals($this->entry_data["status_entry"], $this->entry->getStatusEntry());
70 $this->entry->setStatusEntry("someStatus");
71 $this->assertEquals("someStatus", $this->entry->getStatusEntry());
72 }
73
74 public function testStatusImplementation(): void
75 {
76 $this->assertEquals($this->entry_data["status_implementation"], $this->entry->getStatusImplementation());
77 $this->entry->setStatusImplementation("someStatus");
78 $this->assertEquals("someStatus", $this->entry->getStatusImplementation());
79 }
80
81 public function testSetDescription(): void
82 {
83 $this->assertEquals(new Description($this->entry_data["description"]), $this->entry->getDescription());
84 $this->assertEquals($this->entry_data["description"], $this->entry->getDescriptionAsArray());
85 $this->entry->setDescription(new Description([]));
86 $this->assertEquals(new Description([]), $this->entry->getDescription());
87 $this->assertEquals(array(
88 'purpose' => '',
89 'composition' => '',
90 'effect' => '',
91 'rivals' => array()), $this->entry->getDescriptionAsArray());
92 }
93
94 public function testSetBackground(): void
95 {
96 $this->assertEquals($this->entry_data["background"], $this->entry->getBackground());
97 $this->entry->setBackground("someBackground");
98 $this->assertEquals("someBackground", $this->entry->getBackground());
99 }
100
101 public function testContext(): void
102 {
103 $this->assertEquals($this->entry_data["context"], $this->entry->getContext());
104 $this->entry->setContext([]);
105 $this->assertEquals([], $this->entry->getContext());
106 }
107
108 public function testFeatureWikiReferences(): void
109 {
110 $this->assertEquals($this->entry_data["feature_wiki_references"], $this->entry->getFeatureWikiReferences());
111 $this->entry->setFeatureWikiReferences([]);
112 $this->assertEquals([], $this->entry->getFeatureWikiReferences());
113 }
114
115 public function testRules(): void
116 {
117 $this->assertEquals(new Rules($this->entry_data["rules"]), $this->entry->getRules());
118 $this->assertEquals($this->entry_data["rules"], $this->entry->getRulesAsArray());
119 $this->entry->setRules(new Rules([]));
120 $this->assertEquals(new Rules([]), $this->entry->getRules());
121 }
122
123 public function testSelector(): void
124 {
125 $this->assertEquals($this->entry_data["selector"], $this->entry->getSelector());
126 $this->entry->setSelector("otherSelector");
127 $this->assertEquals("otherSelector", $this->entry->getSelector());
128 }
129
130 public function testLessVariables(): void
131 {
132 $this->assertEquals($this->entry_data["less_variables"], $this->entry->getLessVariables());
133 $this->entry->setLessVariables([]);
134 $this->assertEquals([], $this->entry->getLessVariables());
135 }
136
137 public function testPath(): void
138 {
139 $this->assertEquals($this->entry_data["path"], $this->entry->getPath());
140 $this->entry->setPath("");
141 $this->assertEquals("", $this->entry->getPath());
142 }
143
144 public function testParent(): void
145 {
146 $this->assertEquals($this->entry_data["parent"], $this->entry->getParent());
147 $this->entry->setParent("test");
148 $this->assertEquals("test", $this->entry->getParent());
149 }
150
151 public function testChildren(): void
152 {
153 $this->assertEquals($this->entry_data["children"], $this->entry->getChildren());
154 $this->entry->setChildren([]);
155 $this->assertEquals([], $this->entry->getChildren());
156 $this->entry->addChildren(
157 array(
158 0 => 'Child1',
159 1 => 'Child2'
160 )
161 );
162 $this->assertEquals(['Child1','Child2'], $this->entry->getChildren());
163 $this->entry->addChild('Child3');
164 $this->assertEquals(['Child1','Child2','Child3'], $this->entry->getChildren());
165 }
166
167 public function testExamplePath(): void
168 {
169 $this->assertEquals('components/ILIAS/UI/src/examples/Entry1Title', $this->entry->getExamplesPath());
170 }
171
172 public function testExamplesNull(): void
173 {
174 $this->assertEquals([], $this->entry->getExamples());
175 }
176
177 public function testJsonSerialize(): void
178 {
179 $this->assertEquals(include "components/ILIAS/UI/tests/Crawler/Fixture/EntryFixture.php", $this->entry->jsonSerialize());
180 }
181
182 public function testNamespace(): void
183 {
184 $this->assertEquals($this->entry_data["namespace"], $this->entry->getNamespace());
185 $this->entry->setNamespace("");
186 $this->assertEquals("", $this->entry->getNamespace());
187 }
188}
Stores Information of UI Components parsed from YAML, examples and less files.