ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 34 of file ilSystemStyleStyleLessFileTest.php.

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

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

+ Here is the call graph for this function:

◆ tearDown()

ilSystemStyleStyleLessFileTest::tearDown ( )
protected

Definition at line 50 of file ilSystemStyleStyleLessFileTest.php.

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

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

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

References $file.

◆ testConstructAndRead()

ilSystemStyleStyleLessFileTest::testConstructAndRead ( )

Definition at line 58 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetCategory()

ilSystemStyleStyleLessFileTest::testGetCategory ( )

Definition at line 92 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetContent()

ilSystemStyleStyleLessFileTest::testGetContent ( )

Definition at line 131 of file ilSystemStyleStyleLessFileTest.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 }

References $file.

◆ testGetItems()

ilSystemStyleStyleLessFileTest::testGetItems ( )

Definition at line 102 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetItemsEdgeCases()

ilSystemStyleStyleLessFileTest::testGetItemsEdgeCases ( )

Definition at line 260 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetVariableByName()

ilSystemStyleStyleLessFileTest::testGetVariableByName ( )

Definition at line 72 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetVariableReferences()

ilSystemStyleStyleLessFileTest::testGetVariableReferences ( )

Definition at line 228 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testGetVariableReferencesAsString()

ilSystemStyleStyleLessFileTest::testGetVariableReferencesAsString ( )

Definition at line 240 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadCorrectTypes()

ilSystemStyleStyleLessFileTest::testReadCorrectTypes ( )

Definition at line 63 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadCorrectTypesEdgeCases()

ilSystemStyleStyleLessFileTest::testReadCorrectTypesEdgeCases ( )

Definition at line 252 of file ilSystemStyleStyleLessFileTest.php.

252 {
253 $file = new ilSystemStyleLessFile($this->container->getSkinDirectory()."edge-cases.less");
254
255 $this->assertEquals(3,count($file->getCategories()));
256 $this->assertEquals(7,count($file->getVariablesIds()));
257 $this->assertEquals(4,count($file->getCommentsIds()));
258 }

References $file.

◆ testReadWriteDouble()

ilSystemStyleStyleLessFileTest::testReadWriteDouble ( )

Definition at line 137 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

◆ testReadWriteDoubleFullLess()

ilSystemStyleStyleLessFileTest::testReadWriteDoubleFullLess ( )

Definition at line 149 of file ilSystemStyleStyleLessFileTest.php.

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

References $file.

Field Documentation

◆ $container

ilSystemStyleStyleLessFileTest::$container
protected

Definition at line 25 of file ilSystemStyleStyleLessFileTest.php.

◆ $save_dic

ilSystemStyleStyleLessFileTest::$save_dic = null
protected

Definition at line 32 of file ilSystemStyleStyleLessFileTest.php.

Referenced by tearDown().

◆ $style

ilSystemStyleStyleLessFileTest::$style
protected

Definition at line 30 of file ilSystemStyleStyleLessFileTest.php.

◆ $system_style_config

ilSystemStyleStyleLessFileTest::$system_style_config
protected

Definition at line 20 of file ilSystemStyleStyleLessFileTest.php.


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