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

Member Function Documentation

◆ setUp()

ilSkinStyleLessFileTest::setUp ( )
protected

Definition at line 32 of file ilSkinStyleLessFileTest.php.

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

33  {
34  global $DIC;
35 
36  $DIC = new ilSystemStyleDICMock();
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  }
Class ilLanguageMock.
"color:#CC0000 style
Definition: example_001.php:92
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...
global $DIC
static xCopy($src, $dest)
Recursive copy of a folder.
+ Here is the call graph for this function:

◆ tearDown()

ilSkinStyleLessFileTest::tearDown ( )
protected

Definition at line 47 of file ilSkinStyleLessFileTest.php.

References ilSystemStyleSkinContainer\recursiveRemoveDir().

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

◆ testAddAndWriteItems()

ilSkinStyleLessFileTest::testAddAndWriteItems ( )

Definition at line 187 of file ilSkinStyleLessFileTest.php.

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

References $file.

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

◆ testConstructAndRead()

ilSkinStyleLessFileTest::testConstructAndRead ( )

Definition at line 52 of file ilSkinStyleLessFileTest.php.

References $file.

52  {
53  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
54  $this->assertEquals(14,count($file->getItems()));
55  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testGetCategory()

ilSkinStyleLessFileTest::testGetCategory ( )

Definition at line 86 of file ilSkinStyleLessFileTest.php.

References $file.

86  {
87  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
88 
89  $expected_category1 = new ilSystemStyleLessCategory("Category 1", "Comment Category 1");
90  $expected_category2 = new ilSystemStyleLessCategory("Category 2", "Comment Category 2");
91  $expected_categories = [$expected_category1,$expected_category2];
92 
93  $this->assertEquals($expected_categories,$file->getCategories());
94  }
Capsules data of a less category in the variables to less file.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testGetContent()

ilSkinStyleLessFileTest::testGetContent ( )

Definition at line 125 of file ilSkinStyleLessFileTest.php.

References $file.

125  {
126  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
127  $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
128  $this->assertEquals($expected_content,$file->getContent());
129  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testGetItems()

ilSkinStyleLessFileTest::testGetItems ( )

Definition at line 96 of file ilSkinStyleLessFileTest.php.

References $file.

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

◆ testGetItemsEdgeCases()

ilSkinStyleLessFileTest::testGetItemsEdgeCases ( )

Definition at line 254 of file ilSkinStyleLessFileTest.php.

References $file.

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

◆ testGetVariableByName()

ilSkinStyleLessFileTest::testGetVariableByName ( )

Definition at line 66 of file ilSkinStyleLessFileTest.php.

References $file.

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

◆ testGetVariableReferences()

ilSkinStyleLessFileTest::testGetVariableReferences ( )

Definition at line 222 of file ilSkinStyleLessFileTest.php.

References $file.

222  {
223  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
224 
225  $this->assertEquals(["variable13","variable21"],$file->getReferencesToVariable("variable11"));
226  $this->assertEquals([],$file->getReferencesToVariable("variable12"));
227  $this->assertEquals([],$file->getReferencesToVariable("variable13"));
228 
229  $this->assertEquals(["variable23"],$file->getReferencesToVariable("variable21"));
230  $this->assertEquals([],$file->getReferencesToVariable("variable22"));
231  $this->assertEquals([],$file->getReferencesToVariable("variable23"));
232  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testGetVariableReferencesAsString()

ilSkinStyleLessFileTest::testGetVariableReferencesAsString ( )

Definition at line 234 of file ilSkinStyleLessFileTest.php.

References $file.

234  {
235  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
236 
237  $this->assertEquals("variable13; variable21; ",$file->getReferencesToVariableAsString("variable11"));
238  $this->assertEquals("",$file->getReferencesToVariableAsString("variable12"));
239  $this->assertEquals("",$file->getReferencesToVariableAsString("variable13"));
240 
241  $this->assertEquals("variable23; ",$file->getReferencesToVariableAsString("variable21"));
242  $this->assertEquals("",$file->getReferencesToVariableAsString("variable22"));
243  $this->assertEquals("",$file->getReferencesToVariableAsString("variable23"));
244  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testReadCorrectTypes()

ilSkinStyleLessFileTest::testReadCorrectTypes ( )

Definition at line 57 of file ilSkinStyleLessFileTest.php.

References $file.

57  {
58  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
59 
60  $this->assertEquals(2,count($file->getCategories()));
61  $this->assertEquals(6,count($file->getVariablesIds()));
62  $this->assertEquals(6,count($file->getCommentsIds()));
63  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testReadCorrectTypesEdgeCases()

ilSkinStyleLessFileTest::testReadCorrectTypesEdgeCases ( )

Definition at line 246 of file ilSkinStyleLessFileTest.php.

References $file.

246  {
247  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory()."edge-cases.less");
248 
249  $this->assertEquals(3,count($file->getCategories()));
250  $this->assertEquals(7,count($file->getVariablesIds()));
251  $this->assertEquals(4,count($file->getCommentsIds()));
252  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testReadWriteDouble()

ilSkinStyleLessFileTest::testReadWriteDouble ( )

Definition at line 131 of file ilSkinStyleLessFileTest.php.

References $file.

131  {
132  $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
133 
134  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
135  $file->write();
136  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
137  $file->write();
138  $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
139 
140  $this->assertEquals($expected_content,$file->getContent());
141  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ testReadWriteDoubleFullLess()

ilSkinStyleLessFileTest::testReadWriteDoubleFullLess ( )

Definition at line 143 of file ilSkinStyleLessFileTest.php.

References $file.

143  {
144  $expected_content = file_get_contents($this->container->getSkinDirectory()."full.less");
145 
146  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory()."full.less");
147  $file->write();
148  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory()."full.less");
149  $file->write();
150  $file = new ilSystemStyleLessFile($this->container->getSkinDirectory()."full.less");
151 
152  $this->assertEquals($expected_content,$file->getContent());
153  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

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: