ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 15 of file ilSkinStyleLessFileTest.php.

Member Function Documentation

◆ setUp()

ilSkinStyleLessFileTest::setUp ( )
protected

Definition at line 34 of file ilSkinStyleLessFileTest.php.

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

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

◆ tearDown()

ilSkinStyleLessFileTest::tearDown ( )
protected

Definition at line 49 of file ilSkinStyleLessFileTest.php.

References ilSystemStyleSkinContainer\recursiveRemoveDir().

49  : void
50  {
51  ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
52  }
static recursiveRemoveDir($dir)
Recursive delete of a folder.
+ Here is the call graph for this function:

◆ testAddAndWriteItems()

ilSkinStyleLessFileTest::testAddAndWriteItems ( )

Definition at line 197 of file ilSkinStyleLessFileTest.php.

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

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

◆ testConstructAndRead()

ilSkinStyleLessFileTest::testConstructAndRead ( )

Definition at line 54 of file ilSkinStyleLessFileTest.php.

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

◆ testGetCategory()

ilSkinStyleLessFileTest::testGetCategory ( )

Definition at line 91 of file ilSkinStyleLessFileTest.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  }
Capsules data of a less category in the variables to less file.

◆ testGetContent()

ilSkinStyleLessFileTest::testGetContent ( )

Definition at line 132 of file ilSkinStyleLessFileTest.php.

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

◆ testGetItems()

ilSkinStyleLessFileTest::testGetItems ( )

Definition at line 102 of file ilSkinStyleLessFileTest.php.

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

◆ testGetItemsEdgeCases()

ilSkinStyleLessFileTest::testGetItemsEdgeCases ( )

Definition at line 268 of file ilSkinStyleLessFileTest.php.

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

◆ testGetVariableByName()

ilSkinStyleLessFileTest::testGetVariableByName ( )

Definition at line 70 of file ilSkinStyleLessFileTest.php.

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

◆ testGetVariableReferences()

ilSkinStyleLessFileTest::testGetVariableReferences ( )

Definition at line 233 of file ilSkinStyleLessFileTest.php.

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

◆ testGetVariableReferencesAsString()

ilSkinStyleLessFileTest::testGetVariableReferencesAsString ( )

Definition at line 246 of file ilSkinStyleLessFileTest.php.

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

◆ testReadCorrectTypes()

ilSkinStyleLessFileTest::testReadCorrectTypes ( )

Definition at line 60 of file ilSkinStyleLessFileTest.php.

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

◆ testReadCorrectTypesEdgeCases()

ilSkinStyleLessFileTest::testReadCorrectTypesEdgeCases ( )

Definition at line 259 of file ilSkinStyleLessFileTest.php.

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

◆ testReadWriteDouble()

ilSkinStyleLessFileTest::testReadWriteDouble ( )

Definition at line 139 of file ilSkinStyleLessFileTest.php.

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

◆ testReadWriteDoubleFullLess()

ilSkinStyleLessFileTest::testReadWriteDoubleFullLess ( )

Definition at line 152 of file ilSkinStyleLessFileTest.php.

References ilSystemStyleLessFile\write().

153  {
154  $expected_content = file_get_contents($this->container->getSkinDirectory() . "full.less");
155 
156  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
157  $file->write();
158  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
159  $file->write();
160  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory() . "full.less");
161 
162  $this->assertEquals($expected_content, $file->getContent());
163  }
write()
Write the complete file back to the file system (including comments and random content) ...
+ Here is the call graph for this function:

Field Documentation

◆ $container

ilSkinStyleLessFileTest::$container
protected

Definition at line 27 of file ilSkinStyleLessFileTest.php.

◆ $style

ilSkinStyleLessFileTest::$style
protected

Definition at line 32 of file ilSkinStyleLessFileTest.php.

◆ $system_style_config

ilSkinStyleLessFileTest::$system_style_config
protected

Definition at line 22 of file ilSkinStyleLessFileTest.php.


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