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");
40 mkdir($this->system_style_config->test_skin_temp_path);
44 $this->
style = $this->container->getSkin()->getStyle(
"style1");
55 $this->assertEquals(14, count(
$file->getItems()));
62 $this->assertEquals(2, count(
$file->getCategories()));
63 $this->assertEquals(6, count(
$file->getVariablesIds()));
64 $this->assertEquals(6, count(
$file->getCommentsIds()));
74 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
76 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
78 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
80 $this->assertEquals($expected_variable11,
$file->getVariableByName(
"variable11"));
81 $this->assertEquals($expected_variable12,
$file->getVariableByName(
"variable12"));
82 $this->assertEquals($expected_variable13,
$file->getVariableByName(
"variable13"));
84 $this->assertEquals($expected_variable21,
$file->getVariableByName(
"variable21"));
85 $this->assertEquals($expected_variable22,
$file->getVariableByName(
"variable22"));
86 $this->assertEquals($expected_variable23,
$file->getVariableByName(
"variable23"));
95 $expected_categories = [$expected_category1,$expected_category2];
97 $this->assertEquals($expected_categories,
$file->getCategories());
109 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
115 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
117 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
119 $expected_items = [$expected_category1,
120 $expected_comment2,$expected_comment3,
121 $expected_variable11,$expected_variable12,$expected_variable13,
124 $expected_comment6,$expected_comment7,$expected_comment8,
125 $expected_variable21,$expected_variable22,$expected_variable23];
127 $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());
139 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
147 $this->assertEquals($expected_content,
$file->getContent());
152 $expected_content = file_get_contents($this->container->getSkinDirectory() .
"full.less");
160 $this->assertEquals($expected_content, $file->getContent());
166 $variable =
$file->getVariableByName(
"variable11");
167 $variable->setValue(
"newvalue11");
172 $expected_variable11 =
new ilSystemStyleLessVariable(
"variable11",
"newvalue11",
"comment variable 11",
"Category 1", []);
174 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
180 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
182 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
184 $expected_items = [$expected_category1,
185 $expected_comment2,$expected_comment3,
186 $expected_variable11,$expected_variable12,$expected_variable13,
189 $expected_comment6,$expected_comment7,$expected_comment8,
190 $expected_variable21,$expected_variable22,$expected_variable23];
192 $this->assertEquals($expected_items,
$file->getItems());
204 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
210 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
212 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
214 $expected_items = [$expected_category1,
215 $expected_comment2,$expected_comment3,
216 $expected_variable11,$expected_variable12,$expected_variable13,
219 $expected_comment6,$expected_comment7,$expected_comment8,
220 $expected_variable21,$expected_variable22,$expected_variable23];
222 foreach ($expected_items as $item) {
223 $empty_less->addItem($item);
225 $empty_less->write();
228 $this->assertEquals($expected_items, $new_less->getItems());
235 $this->assertEquals([
"variable13",
"variable21"],
$file->getReferencesToVariable(
"variable11"));
236 $this->assertEquals([],
$file->getReferencesToVariable(
"variable12"));
237 $this->assertEquals([],
$file->getReferencesToVariable(
"variable13"));
239 $this->assertEquals([
"variable23"],
$file->getReferencesToVariable(
"variable21"));
240 $this->assertEquals([],
$file->getReferencesToVariable(
"variable22"));
241 $this->assertEquals([],
$file->getReferencesToVariable(
"variable23"));
248 $this->assertEquals(
"variable13; variable21; ",
$file->getReferencesToVariableAsString(
"variable11"));
249 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable12"));
250 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable13"));
252 $this->assertEquals(
"variable23; ",
$file->getReferencesToVariableAsString(
"variable21"));
253 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable22"));
254 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable23"));
261 $this->assertEquals(3, count(
$file->getCategories()));
262 $this->assertEquals(7, count(
$file->getVariablesIds()));
263 $this->assertEquals(4, count(
$file->getCommentsIds()));
278 $expected_variable21 =
new ilSystemStyleLessVariable(
"variableNoValidSection1",
"value21",
"",
"Category 1 no valid section", []);
279 $expected_variable22 =
new ilSystemStyleLessVariable(
"variableNoValidSection2",
"value22",
"comment",
"Category 1 no valid section", []);
286 $expected_variable32 =
new ilSystemStyleLessVariable(
"variable21",
"floor((@regular * 1.6)) * lighten(@regular, 20%)",
"Hard references",
"Category 2", [
"regular"]);
293 $expected_items = [$expected_comment1,$expected_comment2,
294 $expected_variable11,$expected_variable12,
295 $expected_category1,$expected_variable21,$expected_variable22,
297 $expected_category2,$expected_variable31,$expected_variable32,
299 $expected_category3,$expected_variable41];
301 $this->assertEquals($expected_items,
$file->getItems());
testReadCorrectTypesEdgeCases()
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.
testGetVariableReferencesAsString()
testReadWriteDoubleFullLess()
testGetVariableReferences()
static recursiveRemoveDir($dir)
Recursive delete of a folder.
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.