ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 35 of file ilSystemStyleStyleLessFileTest.php.

36 {
37 global $DIC;
38
39 $this->save_dic = $DIC;
41
42 $this->system_style_config = new ilSystemStyleConfigMock();
43
44 mkdir($this->system_style_config->test_skin_temp_path);
45 ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path, $this->system_style_config->test_skin_temp_path);
46
47 $this->container = ilSystemStyleSkinContainer::generateFromId("skin1", null, $this->system_style_config);
48 $this->style = $this->container->getSkin()->getStyle("style1");
49 }
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()

ilSystemStyleStyleLessFileTest::tearDown ( )
protected

Definition at line 51 of file ilSystemStyleStyleLessFileTest.php.

52 {
53 global $DIC;
55
56 ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
57 }
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 202 of file ilSystemStyleStyleLessFileTest.php.

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

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

References $file.

◆ testConstructAndRead()

ilSystemStyleStyleLessFileTest::testConstructAndRead ( )

Definition at line 59 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetCategory()

ilSystemStyleStyleLessFileTest::testGetCategory ( )

Definition at line 96 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetContent()

ilSystemStyleStyleLessFileTest::testGetContent ( )

Definition at line 137 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetItems()

ilSystemStyleStyleLessFileTest::testGetItems ( )

Definition at line 107 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetItemsEdgeCases()

ilSystemStyleStyleLessFileTest::testGetItemsEdgeCases ( )

Definition at line 273 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetVariableByName()

ilSystemStyleStyleLessFileTest::testGetVariableByName ( )

Definition at line 75 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetVariableReferences()

ilSystemStyleStyleLessFileTest::testGetVariableReferences ( )

Definition at line 238 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetVariableReferencesAsString()

ilSystemStyleStyleLessFileTest::testGetVariableReferencesAsString ( )

Definition at line 251 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadCorrectTypes()

ilSystemStyleStyleLessFileTest::testReadCorrectTypes ( )

Definition at line 65 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadCorrectTypesEdgeCases()

ilSystemStyleStyleLessFileTest::testReadCorrectTypesEdgeCases ( )

Definition at line 264 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadWriteDouble()

ilSystemStyleStyleLessFileTest::testReadWriteDouble ( )

Definition at line 144 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadWriteDoubleFullLess()

ilSystemStyleStyleLessFileTest::testReadWriteDoubleFullLess ( )

Definition at line 157 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

Field Documentation

◆ $container

ilSystemStyleStyleLessFileTest::$container
protected

Definition at line 26 of file ilSystemStyleStyleLessFileTest.php.

◆ $save_dic

ilSystemStyleStyleLessFileTest::$save_dic = null
protected

Definition at line 33 of file ilSystemStyleStyleLessFileTest.php.

Referenced by tearDown().

◆ $style

ilSystemStyleStyleLessFileTest::$style
protected

Definition at line 31 of file ilSystemStyleStyleLessFileTest.php.

◆ $system_style_config

ilSystemStyleStyleLessFileTest::$system_style_config
protected

Definition at line 21 of file ilSystemStyleStyleLessFileTest.php.


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