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");
39 $this->save_dic =
$DIC;
44 mkdir($this->system_style_config->test_skin_temp_path);
48 $this->
style = $this->container->getSkin()->getStyle(
"style1");
62 $this->assertEquals(14, count(
$file->getItems()));
69 $this->assertEquals(2, count(
$file->getCategories()));
70 $this->assertEquals(6, count(
$file->getVariablesIds()));
71 $this->assertEquals(6, count(
$file->getCommentsIds()));
81 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
83 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
85 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
87 $this->assertEquals($expected_variable11,
$file->getVariableByName(
"variable11"));
88 $this->assertEquals($expected_variable12,
$file->getVariableByName(
"variable12"));
89 $this->assertEquals($expected_variable13,
$file->getVariableByName(
"variable13"));
91 $this->assertEquals($expected_variable21,
$file->getVariableByName(
"variable21"));
92 $this->assertEquals($expected_variable22,
$file->getVariableByName(
"variable22"));
93 $this->assertEquals($expected_variable23,
$file->getVariableByName(
"variable23"));
102 $expected_categories = [$expected_category1,$expected_category2];
104 $this->assertEquals($expected_categories,
$file->getCategories());
116 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
122 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
124 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
126 $expected_items = [$expected_category1,
127 $expected_comment2,$expected_comment3,
128 $expected_variable11,$expected_variable12,$expected_variable13,
131 $expected_comment6,$expected_comment7,$expected_comment8,
132 $expected_variable21,$expected_variable22,$expected_variable23];
134 $this->assertEquals($expected_items,
$file->getItems());
140 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
141 $this->assertEquals($expected_content,
$file->getContent());
146 $expected_content = file_get_contents($this->container->getLessVariablesFilePath($this->style->getId()));
154 $this->assertEquals($expected_content,
$file->getContent());
159 $expected_content = file_get_contents($this->container->getSkinDirectory() .
"full.less");
167 $this->assertEquals($expected_content, $file->getContent());
173 $variable =
$file->getVariableByName(
"variable11");
174 $variable->setValue(
"newvalue11");
179 $expected_variable11 =
new ilSystemStyleLessVariable(
"variable11",
"newvalue11",
"comment variable 11",
"Category 1", []);
181 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
187 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
189 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
191 $expected_items = [$expected_category1,
192 $expected_comment2,$expected_comment3,
193 $expected_variable11,$expected_variable12,$expected_variable13,
196 $expected_comment6,$expected_comment7,$expected_comment8,
197 $expected_variable21,$expected_variable22,$expected_variable23];
199 $this->assertEquals($expected_items,
$file->getItems());
211 $expected_variable13 =
new ilSystemStyleLessVariable(
"variable13",
"@variable11",
"comment variable 13",
"Category 1", [
"variable11"]);
217 $expected_variable21 =
new ilSystemStyleLessVariable(
"variable21",
"@variable11",
"comment variable 21",
"Category 2", [
"variable11"]);
219 $expected_variable23 =
new ilSystemStyleLessVariable(
"variable23",
"@variable21",
"comment variable 23",
"Category 2", [
"variable21"]);
221 $expected_items = [$expected_category1,
222 $expected_comment2,$expected_comment3,
223 $expected_variable11,$expected_variable12,$expected_variable13,
226 $expected_comment6,$expected_comment7,$expected_comment8,
227 $expected_variable21,$expected_variable22,$expected_variable23];
229 foreach ($expected_items as $item) {
230 $empty_less->addItem($item);
232 $empty_less->write();
235 $this->assertEquals($expected_items, $new_less->getItems());
242 $this->assertEquals([
"variable13",
"variable21"],
$file->getReferencesToVariable(
"variable11"));
243 $this->assertEquals([],
$file->getReferencesToVariable(
"variable12"));
244 $this->assertEquals([],
$file->getReferencesToVariable(
"variable13"));
246 $this->assertEquals([
"variable23"],
$file->getReferencesToVariable(
"variable21"));
247 $this->assertEquals([],
$file->getReferencesToVariable(
"variable22"));
248 $this->assertEquals([],
$file->getReferencesToVariable(
"variable23"));
255 $this->assertEquals(
"variable13; variable21; ",
$file->getReferencesToVariableAsString(
"variable11"));
256 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable12"));
257 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable13"));
259 $this->assertEquals(
"variable23; ",
$file->getReferencesToVariableAsString(
"variable21"));
260 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable22"));
261 $this->assertEquals(
"",
$file->getReferencesToVariableAsString(
"variable23"));
268 $this->assertEquals(3, count(
$file->getCategories()));
269 $this->assertEquals(7, count(
$file->getVariablesIds()));
270 $this->assertEquals(4, count(
$file->getCommentsIds()));
285 $expected_variable21 =
new ilSystemStyleLessVariable(
"variableNoValidSection1",
"value21",
"",
"Category 1 no valid section", []);
286 $expected_variable22 =
new ilSystemStyleLessVariable(
"variableNoValidSection2",
"value22",
"comment",
"Category 1 no valid section", []);
293 $expected_variable32 =
new ilSystemStyleLessVariable(
"variable21",
"floor((@regular * 1.6)) * lighten(@regular, 20%)",
"Hard references",
"Category 2", [
"regular"]);
300 $expected_items = [$expected_comment1,$expected_comment2,
301 $expected_variable11,$expected_variable12,
302 $expected_category1,$expected_variable21,$expected_variable22,
304 $expected_category2,$expected_variable31,$expected_variable32,
306 $expected_category3,$expected_variable41];
308 $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...
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()