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");
37 protected function setUp() : void
41 $this->save_dic =
$DIC;
46 mkdir($this->system_style_config->test_skin_temp_path);
50 $this->style = $this->container->getSkin()->getStyle(
"style1");
64 $this->assertEquals(14, count($file->getItems()));
71 $this->assertEquals(2, count($file->getCategories()));
72 $this->assertEquals(6, count($file->getVariablesIds()));
73 $this->assertEquals(6, count($file->getCommentsIds()));
83 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
85 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
87 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
89 $this->assertEquals($expected_variable11, $file->getVariableByName(
"variable11"));
90 $this->assertEquals($expected_variable12, $file->getVariableByName(
"variable12"));
91 $this->assertEquals($expected_variable13, $file->getVariableByName(
"variable13"));
93 $this->assertEquals($expected_variable21, $file->getVariableByName(
"variable21"));
94 $this->assertEquals($expected_variable22, $file->getVariableByName(
"variable22"));
95 $this->assertEquals($expected_variable23, $file->getVariableByName(
"variable23"));
100 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
104 $expected_categories = [$expected_category1,$expected_category2];
106 $this->assertEquals($expected_categories, $file->getCategories());
111 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
118 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
124 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
126 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
128 $expected_items = [$expected_category1,
129 $expected_comment2,$expected_comment3,
130 $expected_variable11,$expected_variable12,$expected_variable13,
133 $expected_comment6,$expected_comment7,$expected_comment8,
134 $expected_variable21,$expected_variable22,$expected_variable23];
136 $this->assertEquals($expected_items, $file->getItems());
141 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
142 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
143 $this->assertEquals($expected_content, $file->getContent());
148 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
150 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
152 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
154 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
156 $this->assertEquals($expected_content, $file->getContent());
161 $expected_content = file_get_contents($this->container->getSkinDirectory() .
"full.less");
169 $this->assertEquals($expected_content, $file->getContent());
174 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
175 $variable = $file->getVariableByName(
"variable11");
176 $variable->setValue(
"newvalue11");
181 $expected_variable11 =
new ilSystemStyleLessVariable(
"variable11",
"newvalue11",
"comment variable 11",
"Category 1", []);
183 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
189 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
191 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
193 $expected_items = [$expected_category1,
194 $expected_comment2,$expected_comment3,
195 $expected_variable11,$expected_variable12,$expected_variable13,
198 $expected_comment6,$expected_comment7,$expected_comment8,
199 $expected_variable21,$expected_variable22,$expected_variable23];
201 $this->assertEquals($expected_items, $file->getItems());
213 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
219 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
221 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
223 $expected_items = [$expected_category1,
224 $expected_comment2,$expected_comment3,
225 $expected_variable11,$expected_variable12,$expected_variable13,
228 $expected_comment6,$expected_comment7,$expected_comment8,
229 $expected_variable21,$expected_variable22,$expected_variable23];
231 foreach ($expected_items as $item) {
232 $empty_less->addItem($item);
234 $empty_less->write();
237 $this->assertEquals($expected_items, $new_less->getItems());
242 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
244 $this->assertEquals([
"variable13",
"variable21"], $file->getReferencesToVariable(
"variable11"));
245 $this->assertEquals([], $file->getReferencesToVariable(
"variable12"));
246 $this->assertEquals([], $file->getReferencesToVariable(
"variable13"));
248 $this->assertEquals([
"variable23"], $file->getReferencesToVariable(
"variable21"));
249 $this->assertEquals([], $file->getReferencesToVariable(
"variable22"));
250 $this->assertEquals([], $file->getReferencesToVariable(
"variable23"));
255 $file =
new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId()));
257 $this->assertEquals(
"variable13; variable21; ", $file->getReferencesToVariableAsString(
"variable11"));
258 $this->assertEquals(
"", $file->getReferencesToVariableAsString(
"variable12"));
259 $this->assertEquals(
"", $file->getReferencesToVariableAsString(
"variable13"));
261 $this->assertEquals(
"variable23; ", $file->getReferencesToVariableAsString(
"variable21"));
262 $this->assertEquals(
"", $file->getReferencesToVariableAsString(
"variable22"));
263 $this->assertEquals(
"", $file->getReferencesToVariableAsString(
"variable23"));
270 $this->assertEquals(3, count($file->getCategories()));
271 $this->assertEquals(7, count($file->getVariablesIds()));
272 $this->assertEquals(4, count($file->getCommentsIds()));
287 $expected_variable21 =
new ilSystemStyleLessVariable(
"variableNoValidSection1",
"value21",
"",
"Category 1 no valid section", []);
288 $expected_variable22 =
new ilSystemStyleLessVariable(
"variableNoValidSection2",
"value22",
"comment",
"Category 1 no valid section", []);
295 $expected_variable32 =
new ilSystemStyleLessVariable(
"variable21",
"floor((@regular * 1.6)) * lighten(@regular, 20%)",
"Hard references",
"Category 2", [
"regular"]);
302 $expected_items = [$expected_comment1,$expected_comment2,
303 $expected_variable11,$expected_variable12,
304 $expected_category1,$expected_variable21,$expected_variable22,
306 $expected_category2,$expected_variable31,$expected_variable32,
308 $expected_category3,$expected_variable41];
310 $this->assertEquals($expected_items, $file->getItems());
write()
Write the complete file back to the file system (including comments and random content) ...
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...
static xCopy($src, $dest)
Recursive copy of a folder.
testGetVariableReferences()
testReadCorrectTypesEdgeCases()