2 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
3 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinXML.php");
4 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleSkinContainer.php");
5 include_once(
"./Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php");
6 include_once(
"Services/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php");
7 include_once(
"Services/Style/System/test/fixtures/mocks/ilSystemStyleDICMock.php");
38 $this->save_dic =
$DIC;
43 mkdir($this->system_style_config->test_skin_temp_path);
47 $this->
style = $this->container->getSkin()->getStyle(
"style1");
60 $this->assertEquals(14,count(
$file->getItems()));
66 $this->assertEquals(2,count(
$file->getCategories()));
67 $this->assertEquals(6,count(
$file->getVariablesIds()));
68 $this->assertEquals(6,count(
$file->getCommentsIds()));
77 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
79 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
81 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
83 $this->assertEquals($expected_variable11,
$file->getVariableByName(
"variable11"));
84 $this->assertEquals($expected_variable12,
$file->getVariableByName(
"variable12"));
85 $this->assertEquals($expected_variable13,
$file->getVariableByName(
"variable13"));
87 $this->assertEquals($expected_variable21,
$file->getVariableByName(
"variable21"));
88 $this->assertEquals($expected_variable22,
$file->getVariableByName(
"variable22"));
89 $this->assertEquals($expected_variable23,
$file->getVariableByName(
"variable23"));
97 $expected_categories = [$expected_category1,$expected_category2];
99 $this->assertEquals($expected_categories,
$file->getCategories());
110 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
116 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
118 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
120 $expected_items = [$expected_category1,
121 $expected_comment2,$expected_comment3,
122 $expected_variable11,$expected_variable12,$expected_variable13,
125 $expected_comment6,$expected_comment7,$expected_comment8,
126 $expected_variable21,$expected_variable22,$expected_variable23];
128 $this->assertEquals($expected_items,
$file->getItems());
133 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
134 $this->assertEquals($expected_content,
$file->getContent());
138 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
146 $this->assertEquals($expected_content,
$file->getContent());
150 $expected_content = file_get_contents($this->container->getSkinDirectory().
"full.less");
158 $this->assertEquals($expected_content,
$file->getContent());
163 $variable =
$file->getVariableByName(
"variable11");
164 $variable->setValue(
"newvalue11");
169 $expected_variable11 =
new ilSystemStyleLessVariable(
"variable11",
"newvalue11",
"comment variable 11",
"Category 1", []);
171 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
177 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
179 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
181 $expected_items = [$expected_category1,
182 $expected_comment2,$expected_comment3,
183 $expected_variable11,$expected_variable12,$expected_variable13,
186 $expected_comment6,$expected_comment7,$expected_comment8,
187 $expected_variable21,$expected_variable22,$expected_variable23];
189 $this->assertEquals($expected_items,
$file->getItems());
201 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
207 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
209 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
211 $expected_items = [$expected_category1,
212 $expected_comment2,$expected_comment3,
213 $expected_variable11,$expected_variable12,$expected_variable13,
216 $expected_comment6,$expected_comment7,$expected_comment8,
217 $expected_variable21,$expected_variable22,$expected_variable23];
219 foreach($expected_items as $item){
220 $empty_less->addItem($item);
222 $empty_less->write();
225 $this->assertEquals($expected_items,$new_less->getItems());
231 $this->assertEquals([
"variable13",
"variable21"],
$file->getReferencesToVariable(
"variable11"));
232 $this->assertEquals([],
$file->getReferencesToVariable(
"variable12"));
233 $this->assertEquals([],
$file->getReferencesToVariable(
"variable13"));
235 $this->assertEquals([
"variable23"],
$file->getReferencesToVariable(
"variable21"));
236 $this->assertEquals([],
$file->getReferencesToVariable(
"variable22"));
237 $this->assertEquals([],
$file->getReferencesToVariable(
"variable23"));
243 $this->assertEquals(
"variable13; variable21; ",
$file->getReferencesToVariableAsString(
"variable11"));
244 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable12"));
245 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable13"));
247 $this->assertEquals(
"variable23; ",
$file->getReferencesToVariableAsString(
"variable21"));
248 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable22"));
249 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable23"));
255 $this->assertEquals(3,count(
$file->getCategories()));
256 $this->assertEquals(7,count(
$file->getVariablesIds()));
257 $this->assertEquals(4,count(
$file->getCommentsIds()));
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", []);
279 $expected_variable32 =
new ilSystemStyleLessVariable(
"variable21",
"floor((@regular * 1.6)) * lighten(@regular, 20%)",
"Hard references",
"Category 2", [
"regular"]);
286 $expected_items = [$expected_comment1,$expected_comment2,
287 $expected_variable11,$expected_variable12,
288 $expected_category1,$expected_variable21,$expected_variable22,
290 $expected_category2,$expected_variable31,$expected_variable32,
292 $expected_category3,$expected_variable41];
294 $this->assertEquals($expected_items,
$file->getItems());
Capsules data of a less category in the variables to less file.
testReadWriteDoubleFullLess()
static recursiveRemoveDir($dir)
Recursive delete of a folder.
testGetVariableReferencesAsString()
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...
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static xCopy($src, $dest)
Recursive copy of a folder.
testGetVariableReferences()
testReadCorrectTypesEdgeCases()