ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSkinStyleLessFileTest Class Reference
+ Inheritance diagram for ilSkinStyleLessFileTest:
+ Collaboration diagram for ilSkinStyleLessFileTest:

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
 

Detailed Description

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$*

Definition at line 13 of file ilSkinStyleLessFileTest.php.

Member Function Documentation

◆ setUp()

ilSkinStyleLessFileTest::setUp ( )
protected

Definition at line 32 of file ilSkinStyleLessFileTest.php.

33 {
34 global $DIC;
35
37
38 $this->system_style_config = new ilSystemStyleConfigMock();
39
40 mkdir($this->system_style_config->test_skin_temp_path);
41 ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path, $this->system_style_config->test_skin_temp_path);
42
43 $this->container = ilSystemStyleSkinContainer::generateFromId("skin1", null, $this->system_style_config);
44 $this->style = $this->container->getSkin()->getStyle("style1");
45 }
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: saml.php:7

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

+ Here is the call graph for this function:

◆ tearDown()

ilSkinStyleLessFileTest::tearDown ( )
protected

Definition at line 47 of file ilSkinStyleLessFileTest.php.

48 {
49 ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
50 }
static recursiveRemoveDir($dir)
Recursive delete of a folder.

References ilSystemStyleSkinContainer\recursiveRemoveDir().

+ Here is the call graph for this function:

◆ testAddAndWriteItems()

ilSkinStyleLessFileTest::testAddAndWriteItems ( )

Definition at line 195 of file ilSkinStyleLessFileTest.php.

196 {
197 $empty_less = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "empty.less");
198
199 $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
200 $expected_comment2 = new ilSystemStyleLessComment("// Random Section 1");
201 $expected_comment3 = new ilSystemStyleLessComment("");
202 $expected_variable11 = new ilSystemStyleLessVariable("variable11", "value11", "comment variable 11", "Category 1", []);
203 $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12", "Category 1", []);
204 $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13", "Category 1", ["variable11"]);
205 $expected_comment4 = new ilSystemStyleLessComment("");
206 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
207 $expected_comment6 = new ilSystemStyleLessComment("/**");
208 $expected_comment7 = new ilSystemStyleLessComment(" Random Section 2 **/");
209 $expected_comment8 = new ilSystemStyleLessComment("");
210 $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21", "Category 2", ["variable11"]);
211 $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22", "Category 2", []);
212 $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23", "Category 2", ["variable21"]);
213
214 $expected_items = [$expected_category1,
215 $expected_comment2,$expected_comment3,
216 $expected_variable11,$expected_variable12,$expected_variable13,
217 $expected_comment4,
218 $expected_category2,
219 $expected_comment6,$expected_comment7,$expected_comment8,
220 $expected_variable21,$expected_variable22,$expected_variable23];
221
222 foreach ($expected_items as $item) {
223 $empty_less->addItem($item);
224 }
225 $empty_less->write();
226
227 $new_less = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "empty.less");
228 $this->assertEquals($expected_items, $new_less->getItems());
229 }
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()

ilSkinStyleLessFileTest::testChangeVariable ( )

Definition at line 163 of file ilSkinStyleLessFileTest.php.

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

◆ testConstructAndRead()

ilSkinStyleLessFileTest::testConstructAndRead ( )

Definition at line 52 of file ilSkinStyleLessFileTest.php.

53 {
54 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
55 $this->assertEquals(14, count($file->getItems()));
56 }

◆ testGetCategory()

ilSkinStyleLessFileTest::testGetCategory ( )

Definition at line 89 of file ilSkinStyleLessFileTest.php.

90 {
91 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
92
93 $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
94 $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
95 $expected_categories = [$expected_category1,$expected_category2];
96
97 $this->assertEquals($expected_categories, $file->getCategories());
98 }

◆ testGetContent()

ilSkinStyleLessFileTest::testGetContent ( )

Definition at line 130 of file ilSkinStyleLessFileTest.php.

131 {
132 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
133 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
134 $this->assertEquals($expected_content, $file->getContent());
135 }

◆ testGetItems()

ilSkinStyleLessFileTest::testGetItems ( )

Definition at line 100 of file ilSkinStyleLessFileTest.php.

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

◆ testGetItemsEdgeCases()

ilSkinStyleLessFileTest::testGetItemsEdgeCases ( )

Definition at line 266 of file ilSkinStyleLessFileTest.php.

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

◆ testGetVariableByName()

ilSkinStyleLessFileTest::testGetVariableByName ( )

Definition at line 68 of file ilSkinStyleLessFileTest.php.

69 {
70 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
71
72 $expected_variable11 = new ilSystemStyleLessVariable("variable11", "value11", "comment variable 11", "Category 1", []);
73 $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12", "Category 1", []);
74 $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13", "Category 1", ["variable11"]);
75
76 $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21", "Category 2", ["variable11"]);
77 $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22", "Category 2", []);
78 $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23", "Category 2", ["variable21"]);
79
80 $this->assertEquals($expected_variable11, $file->getVariableByName("variable11"));
81 $this->assertEquals($expected_variable12, $file->getVariableByName("variable12"));
82 $this->assertEquals($expected_variable13, $file->getVariableByName("variable13"));
83
84 $this->assertEquals($expected_variable21, $file->getVariableByName("variable21"));
85 $this->assertEquals($expected_variable22, $file->getVariableByName("variable22"));
86 $this->assertEquals($expected_variable23, $file->getVariableByName("variable23"));
87 }

◆ testGetVariableReferences()

ilSkinStyleLessFileTest::testGetVariableReferences ( )

Definition at line 231 of file ilSkinStyleLessFileTest.php.

232 {
233 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
234
235 $this->assertEquals(["variable13","variable21"], $file->getReferencesToVariable("variable11"));
236 $this->assertEquals([], $file->getReferencesToVariable("variable12"));
237 $this->assertEquals([], $file->getReferencesToVariable("variable13"));
238
239 $this->assertEquals(["variable23"], $file->getReferencesToVariable("variable21"));
240 $this->assertEquals([], $file->getReferencesToVariable("variable22"));
241 $this->assertEquals([], $file->getReferencesToVariable("variable23"));
242 }

◆ testGetVariableReferencesAsString()

ilSkinStyleLessFileTest::testGetVariableReferencesAsString ( )

Definition at line 244 of file ilSkinStyleLessFileTest.php.

245 {
246 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
247
248 $this->assertEquals("variable13; variable21; ", $file->getReferencesToVariableAsString("variable11"));
249 $this->assertEquals("", $file->getReferencesToVariableAsString("variable12"));
250 $this->assertEquals("", $file->getReferencesToVariableAsString("variable13"));
251
252 $this->assertEquals("variable23; ", $file->getReferencesToVariableAsString("variable21"));
253 $this->assertEquals("", $file->getReferencesToVariableAsString("variable22"));
254 $this->assertEquals("", $file->getReferencesToVariableAsString("variable23"));
255 }

◆ testReadCorrectTypes()

ilSkinStyleLessFileTest::testReadCorrectTypes ( )

Definition at line 58 of file ilSkinStyleLessFileTest.php.

59 {
60 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
61
62 $this->assertEquals(2, count($file->getCategories()));
63 $this->assertEquals(6, count($file->getVariablesIds()));
64 $this->assertEquals(6, count($file->getCommentsIds()));
65 }

◆ testReadCorrectTypesEdgeCases()

ilSkinStyleLessFileTest::testReadCorrectTypesEdgeCases ( )

Definition at line 257 of file ilSkinStyleLessFileTest.php.

258 {
259 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "edge-cases.less");
260
261 $this->assertEquals(3, count($file->getCategories()));
262 $this->assertEquals(7, count($file->getVariablesIds()));
263 $this->assertEquals(4, count($file->getCommentsIds()));
264 }

◆ testReadWriteDouble()

ilSkinStyleLessFileTest::testReadWriteDouble ( )

Definition at line 137 of file ilSkinStyleLessFileTest.php.

138 {
139 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
140
141 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
142 $file->write();
143 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
144 $file->write();
145 $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
146
147 $this->assertEquals($expected_content, $file->getContent());
148 }

◆ testReadWriteDoubleFullLess()

ilSkinStyleLessFileTest::testReadWriteDoubleFullLess ( )

Definition at line 150 of file ilSkinStyleLessFileTest.php.

151 {
152 $expected_content = file_get_contents($this->container->getSkinDirectory() . "full.less");
153
154 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
155 $file->write();
156 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
157 $file->write();
158 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
159
160 $this->assertEquals($expected_content, $file->getContent());
161 }

Field Documentation

◆ $container

ilSkinStyleLessFileTest::$container
protected

Definition at line 25 of file ilSkinStyleLessFileTest.php.

◆ $style

ilSkinStyleLessFileTest::$style
protected

Definition at line 30 of file ilSkinStyleLessFileTest.php.

◆ $system_style_config

ilSkinStyleLessFileTest::$system_style_config
protected

Definition at line 20 of file ilSkinStyleLessFileTest.php.


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