ILIAS  release_7 Revision v7.30-3-g800a261c036
ilSystemStyleStyleLessFileTest Class Reference
+ Inheritance diagram for ilSystemStyleStyleLessFileTest:
+ Collaboration diagram for ilSystemStyleStyleLessFileTest:

Public Member Functions

 testConstructAndRead ()
 
 testReadCorrectTypes ()
 
 testGetVariableByName ()
 
 testGetCategory ()
 
 testGetItems ()
 
 testGetContent ()
 
 testReadWriteDouble ()
 
 testReadWriteDoubleFullLess ()
 
 testChangeVariable ()
 
 testAddAndWriteItems ()
 
 testGetVariableReferences ()
 
 testGetVariableReferencesAsString ()
 
 testReadCorrectTypesEdgeCases ()
 
 testGetItemsEdgeCases ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $system_style_config
 
 $container
 
 $style
 
 $save_dic = null
 

Detailed Description

Member Function Documentation

◆ setUp()

ilSystemStyleStyleLessFileTest::setUp ( )
protected

Definition at line 37 of file ilSystemStyleStyleLessFileTest.php.

37 : void
38 {
39 global $DIC;
40
41 $this->save_dic = $DIC;
43
44 $this->system_style_config = new ilSystemStyleConfigMock();
45
46 mkdir($this->system_style_config->test_skin_temp_path);
47 ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path, $this->system_style_config->test_skin_temp_path);
48
49 $this->container = ilSystemStyleSkinContainer::generateFromId("skin1", null, $this->system_style_config);
50 $this->style = $this->container->getSkin()->getStyle("style1");
51 }
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Class ilLanguageMock.
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
static xCopy($src, $dest)
Recursive copy of a folder.
global $DIC
Definition: goto.php:24

References $DIC, ilSystemStyleSkinContainer\generateFromId(), and ilSystemStyleSkinContainer\xCopy().

+ Here is the call graph for this function:

◆ tearDown()

ilSystemStyleStyleLessFileTest::tearDown ( )
protected

Definition at line 53 of file ilSystemStyleStyleLessFileTest.php.

53 : void
54 {
55 global $DIC;
57
58 ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
59 }
static recursiveRemoveDir($dir)
Recursive delete of a folder.

References $DIC, $save_dic, and ilSystemStyleSkinContainer\recursiveRemoveDir().

+ Here is the call graph for this function:

◆ testAddAndWriteItems()

ilSystemStyleStyleLessFileTest::testAddAndWriteItems ( )

Definition at line 204 of file ilSystemStyleStyleLessFileTest.php.

205 {
206 $empty_less = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "empty.less");
207
208 $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
209 $expected_comment2 = new ilSystemStyleLessComment("// Random Section 1");
210 $expected_comment3 = new ilSystemStyleLessComment("");
211 $expected_variable11 = new ilSystemStyleLessVariable("variable11", "value11", "comment variable 11", "Category 1", []);
212 $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12", "Category 1", []);
213 $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13", "Category 1", ["variable11"]);
214 $expected_comment4 = new ilSystemStyleLessComment("");
215 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
216 $expected_comment6 = new ilSystemStyleLessComment("/**");
217 $expected_comment7 = new ilSystemStyleLessComment(" Random Section 2 **/");
218 $expected_comment8 = new ilSystemStyleLessComment("");
219 $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21", "Category 2", ["variable11"]);
220 $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22", "Category 2", []);
221 $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23", "Category 2", ["variable21"]);
222
223 $expected_items = [$expected_category1,
224 $expected_comment2,$expected_comment3,
225 $expected_variable11,$expected_variable12,$expected_variable13,
226 $expected_comment4,
227 $expected_category2,
228 $expected_comment6,$expected_comment7,$expected_comment8,
229 $expected_variable21,$expected_variable22,$expected_variable23];
230
231 foreach ($expected_items as $item) {
232 $empty_less->addItem($item);
233 }
234 $empty_less->write();
235
236 $new_less = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "empty.less");
237 $this->assertEquals($expected_items, $new_less->getItems());
238 }
Capsules data of a less category in the variables to less file.
Capsules all data which is neither part of a variable or category structure in the less file.

◆ testChangeVariable()

ilSystemStyleStyleLessFileTest::testChangeVariable ( )

Definition at line 172 of file ilSystemStyleStyleLessFileTest.php.

173 {
174 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
175 $variable = $file->getVariableByName("variable11");
176 $variable->setValue("newvalue11");
177
178 $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
179 $expected_comment2 = new ilSystemStyleLessComment("// Random Section 1");
180 $expected_comment3 = new ilSystemStyleLessComment("");
181 $expected_variable11 = new ilSystemStyleLessVariable("variable11", "newvalue11", "comment variable 11", "Category 1", []);
182 $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12", "Category 1", []);
183 $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13", "Category 1", ["variable11"]);
184 $expected_comment4 = new ilSystemStyleLessComment("");
185 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
186 $expected_comment6 = new ilSystemStyleLessComment("/**");
187 $expected_comment7 = new ilSystemStyleLessComment(" Random Section 2 **/");
188 $expected_comment8 = new ilSystemStyleLessComment("");
189 $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21", "Category 2", ["variable11"]);
190 $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22", "Category 2", []);
191 $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23", "Category 2", ["variable21"]);
192
193 $expected_items = [$expected_category1,
194 $expected_comment2,$expected_comment3,
195 $expected_variable11,$expected_variable12,$expected_variable13,
196 $expected_comment4,
197 $expected_category2,
198 $expected_comment6,$expected_comment7,$expected_comment8,
199 $expected_variable21,$expected_variable22,$expected_variable23];
200
201 $this->assertEquals($expected_items, $file->getItems());
202 }

◆ testConstructAndRead()

ilSystemStyleStyleLessFileTest::testConstructAndRead ( )

Definition at line 61 of file ilSystemStyleStyleLessFileTest.php.

62 {
63 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
64 $this->assertEquals(14, count($file->getItems()));
65 }

◆ testGetCategory()

ilSystemStyleStyleLessFileTest::testGetCategory ( )

Definition at line 98 of file ilSystemStyleStyleLessFileTest.php.

99 {
100 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
101
102 $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
103 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
104 $expected_categories = [$expected_category1,$expected_category2];
105
106 $this->assertEquals($expected_categories, $file->getCategories());
107 }

◆ testGetContent()

ilSystemStyleStyleLessFileTest::testGetContent ( )

Definition at line 139 of file ilSystemStyleStyleLessFileTest.php.

140 {
141 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
142 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
143 $this->assertEquals($expected_content, $file->getContent());
144 }

◆ testGetItems()

ilSystemStyleStyleLessFileTest::testGetItems ( )

Definition at line 109 of file ilSystemStyleStyleLessFileTest.php.

110 {
111 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
112
113 $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
114 $expected_comment2 = new ilSystemStyleLessComment("// Random Section 1");
115 $expected_comment3 = new ilSystemStyleLessComment("");
116 $expected_variable11 = new ilSystemStyleLessVariable("variable11", "value11", "comment variable 11", "Category 1", []);
117 $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12", "Category 1", []);
118 $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13", "Category 1", ["variable11"]);
119 $expected_comment4 = new ilSystemStyleLessComment("");
120 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
121 $expected_comment6 = new ilSystemStyleLessComment("/**");
122 $expected_comment7 = new ilSystemStyleLessComment(" Random Section 2 **/");
123 $expected_comment8 = new ilSystemStyleLessComment("");
124 $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21", "Category 2", ["variable11"]);
125 $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22", "Category 2", []);
126 $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23", "Category 2", ["variable21"]);
127
128 $expected_items = [$expected_category1,
129 $expected_comment2,$expected_comment3,
130 $expected_variable11,$expected_variable12,$expected_variable13,
131 $expected_comment4,
132 $expected_category2,
133 $expected_comment6,$expected_comment7,$expected_comment8,
134 $expected_variable21,$expected_variable22,$expected_variable23];
135
136 $this->assertEquals($expected_items, $file->getItems());
137 }

◆ testGetItemsEdgeCases()

ilSystemStyleStyleLessFileTest::testGetItemsEdgeCases ( )

Definition at line 275 of file ilSystemStyleStyleLessFileTest.php.

276 {
277 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "edge-cases.less");
278
279 $expected_comment1 = new ilSystemStyleLessComment("// No Category to start");
280 $expected_comment2 = new ilSystemStyleLessComment("");
281
282 $expected_variable11 = new ilSystemStyleLessVariable("variableNoCategory1", "value11", "comment variable 11", "", []);
283 $expected_variable12 = new ilSystemStyleLessVariable("variableNoCategory1NoComment", "value12", "", "", []);
284
285 $expected_category1 = new ilSystemStyleLessCategory("Category 1 no valid section", "");
286
287 $expected_variable21 = new ilSystemStyleLessVariable("variableNoValidSection1", "value21", "", "Category 1 no valid section", []);
288 $expected_variable22 = new ilSystemStyleLessVariable("variableNoValidSection2", "value22", "comment", "Category 1 no valid section", []);
289
290 $expected_comment3 = new ilSystemStyleLessComment("");
291
292 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
293
294 $expected_variable31 = new ilSystemStyleLessVariable("regular", "value", "Hard references id", "Category 2", []);
295 $expected_variable32 = new ilSystemStyleLessVariable("variable21", "floor((@regular * 1.6)) * lighten(@regular, 20%)", "Hard references", "Category 2", ["regular"]);
296
297 $expected_comment4 = new ilSystemStyleLessComment("");
298
299 $expected_category3 = new ilSystemStyleLessCategory("Category 3", "No Section Between");
300 $expected_variable41 = new ilSystemStyleLessVariable("variable3", "value3", "", "Category 3", []);
301
302 $expected_items = [$expected_comment1,$expected_comment2,
303 $expected_variable11,$expected_variable12,
304 $expected_category1,$expected_variable21,$expected_variable22,
305 $expected_comment3,
306 $expected_category2,$expected_variable31,$expected_variable32,
307 $expected_comment4,
308 $expected_category3,$expected_variable41];
309
310 $this->assertEquals($expected_items, $file->getItems());
311 }

◆ testGetVariableByName()

ilSystemStyleStyleLessFileTest::testGetVariableByName ( )

Definition at line 77 of file ilSystemStyleStyleLessFileTest.php.

78 {
79 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
80
81 $expected_variable11 = new ilSystemStyleLessVariable("variable11", "value11", "comment variable 11", "Category 1", []);
82 $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12", "Category 1", []);
83 $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13", "Category 1", ["variable11"]);
84
85 $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21", "Category 2", ["variable11"]);
86 $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22", "Category 2", []);
87 $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23", "Category 2", ["variable21"]);
88
89 $this->assertEquals($expected_variable11, $file->getVariableByName("variable11"));
90 $this->assertEquals($expected_variable12, $file->getVariableByName("variable12"));
91 $this->assertEquals($expected_variable13, $file->getVariableByName("variable13"));
92
93 $this->assertEquals($expected_variable21, $file->getVariableByName("variable21"));
94 $this->assertEquals($expected_variable22, $file->getVariableByName("variable22"));
95 $this->assertEquals($expected_variable23, $file->getVariableByName("variable23"));
96 }

◆ testGetVariableReferences()

ilSystemStyleStyleLessFileTest::testGetVariableReferences ( )

Definition at line 240 of file ilSystemStyleStyleLessFileTest.php.

241 {
242 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
243
244 $this->assertEquals(["variable13","variable21"], $file->getReferencesToVariable("variable11"));
245 $this->assertEquals([], $file->getReferencesToVariable("variable12"));
246 $this->assertEquals([], $file->getReferencesToVariable("variable13"));
247
248 $this->assertEquals(["variable23"], $file->getReferencesToVariable("variable21"));
249 $this->assertEquals([], $file->getReferencesToVariable("variable22"));
250 $this->assertEquals([], $file->getReferencesToVariable("variable23"));
251 }

◆ testGetVariableReferencesAsString()

ilSystemStyleStyleLessFileTest::testGetVariableReferencesAsString ( )

Definition at line 253 of file ilSystemStyleStyleLessFileTest.php.

254 {
255 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
256
257 $this->assertEquals("variable13; variable21; ", $file->getReferencesToVariableAsString("variable11"));
258 $this->assertEquals("", $file->getReferencesToVariableAsString("variable12"));
259 $this->assertEquals("", $file->getReferencesToVariableAsString("variable13"));
260
261 $this->assertEquals("variable23; ", $file->getReferencesToVariableAsString("variable21"));
262 $this->assertEquals("", $file->getReferencesToVariableAsString("variable22"));
263 $this->assertEquals("", $file->getReferencesToVariableAsString("variable23"));
264 }

◆ testReadCorrectTypes()

ilSystemStyleStyleLessFileTest::testReadCorrectTypes ( )

Definition at line 67 of file ilSystemStyleStyleLessFileTest.php.

68 {
69 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
70
71 $this->assertEquals(2, count($file->getCategories()));
72 $this->assertEquals(6, count($file->getVariablesIds()));
73 $this->assertEquals(6, count($file->getCommentsIds()));
74 }

◆ testReadCorrectTypesEdgeCases()

ilSystemStyleStyleLessFileTest::testReadCorrectTypesEdgeCases ( )

Definition at line 266 of file ilSystemStyleStyleLessFileTest.php.

267 {
268 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "edge-cases.less");
269
270 $this->assertEquals(3, count($file->getCategories()));
271 $this->assertEquals(7, count($file->getVariablesIds()));
272 $this->assertEquals(4, count($file->getCommentsIds()));
273 }

◆ testReadWriteDouble()

ilSystemStyleStyleLessFileTest::testReadWriteDouble ( )

Definition at line 146 of file ilSystemStyleStyleLessFileTest.php.

147 {
148 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
149
150 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
151 $file->write();
152 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
153 $file->write();
154 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
155
156 $this->assertEquals($expected_content, $file->getContent());
157 }

◆ testReadWriteDoubleFullLess()

ilSystemStyleStyleLessFileTest::testReadWriteDoubleFullLess ( )

Definition at line 159 of file ilSystemStyleStyleLessFileTest.php.

160 {
161 $expected_content = file_get_contents($this->container->getSkinDirectory() . "full.less");
162
163 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
164 $file->write();
165 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
166 $file->write();
167 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
168
169 $this->assertEquals($expected_content, $file->getContent());
170 }

Field Documentation

◆ $container

ilSystemStyleStyleLessFileTest::$container
protected

Definition at line 28 of file ilSystemStyleStyleLessFileTest.php.

◆ $save_dic

ilSystemStyleStyleLessFileTest::$save_dic = null
protected

Definition at line 35 of file ilSystemStyleStyleLessFileTest.php.

Referenced by tearDown().

◆ $style

ilSystemStyleStyleLessFileTest::$style
protected

Definition at line 33 of file ilSystemStyleStyleLessFileTest.php.

◆ $system_style_config

ilSystemStyleStyleLessFileTest::$system_style_config
protected

Definition at line 23 of file ilSystemStyleStyleLessFileTest.php.


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