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