19 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
20 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinXML.php");
21 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleSkinContainer.php");
22 include_once(
"Services/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php");
23 include_once(
"Services/Style/System/test/fixtures/mocks/ilSystemStyleDICMock.php");
25 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleMessageStack.php");
26 include_once(
"Services/Utilities/classes/class.ilUtil.php");
61 protected function setUp() : void
65 $this->save_dic =
$DIC;
68 if (!defined(
'PATH_TO_LESSC')) {
69 if (file_exists(
"ilias.ini.php")) {
70 $ini = parse_ini_file(
"ilias.ini.php",
true);
71 define(
'PATH_TO_LESSC',
$ini[
'tools'][
'lessc'] ??
'');
73 define(
'PATH_TO_LESSC',
"");
77 $this->skin =
new ilSkinXML(
"skin1",
"skin 1");
80 $this->style1->setCssFile(
"style1css");
81 $this->style1->setImageDirectory(
"style1image");
82 $this->style1->setSoundDirectory(
"style1sound");
83 $this->style1->setFontDirectory(
"style1font");
86 $this->style2->setCssFile(
"style2css");
87 $this->style2->setImageDirectory(
"style2image");
88 $this->style2->setSoundDirectory(
"style2sound");
89 $this->style2->setFontDirectory(
"style2font");
93 mkdir($this->system_style_config->test_skin_temp_path);
108 $this->assertEquals(
$container->getSkin()->getId(), $this->skin->getId());
109 $this->assertEquals(
$container->getSkin()->getName(), $this->skin->getName());
111 $this->assertEquals(
$container->getSkin()->getStyle($this->style1->getId()), $this->style1);
112 $this->assertEquals(
$container->getSkin()->getStyle($this->style2->getId()), $this->style2);
122 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin"));
124 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin"));
131 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId()));
140 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin2"));
142 $container->getSkin()->setId($this->skin->getId());
144 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin2"));
150 $new_style->setCssFile(
"style1new");
151 $new_style->setImageDirectory(
"style1newimage");
152 $new_style->setSoundDirectory(
"style1newsound");
153 $new_style->setFontDirectory(
"style1newfont");
157 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
158 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
159 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
160 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
161 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
162 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
164 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newimage"));
165 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newsound"));
166 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newfont"));
167 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.css"));
168 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.less"));
169 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new-variables.less"));
173 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
174 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
175 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
176 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
177 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
178 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
180 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newimage"));
181 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newsound"));
182 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newfont"));
183 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.css"));
184 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.less"));
185 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new-variables.less"));
194 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
195 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
196 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
197 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
198 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
199 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
201 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2image"));
202 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2sound"));
203 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2font"));
204 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2css.css"));
205 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2css.less"));
206 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2css-variables.less"));
214 $old_style = clone $skin->getStyle($this->style1->getId());
215 $new_style = $skin->getStyle($this->style1->getId());
217 $new_style->setId(
"style1new");
218 $new_style->setName(
"new Style");
219 $new_style->setCssFile(
"style1new");
220 $new_style->setImageDirectory(
"style1newimage");
221 $new_style->setSoundDirectory(
"style1newsound");
222 $new_style->setFontDirectory(
"style1newfont");
224 $container->updateStyle($new_style->getId(), $old_style);
226 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
227 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
228 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
229 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
230 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
231 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
233 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newimage"));
234 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newsound"));
235 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newfont"));
236 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.css"));
237 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.less"));
238 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new-variables.less"));
246 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId()));
248 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId()));
256 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
259 $skin_copy = $container_copy->getSkin();
261 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
262 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId()));
263 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1image"));
264 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1sound"));
265 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1font"));
266 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.css"));
267 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.less"));
268 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css-variables.less"));
270 $this->assertEquals($skin->getName() .
" Copy", $skin_copy->getName());
271 $this->assertEquals(
"0.1", $skin_copy->getVersion());
279 $skin_copy = $container_copy->getSkin();
281 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"inject"));
282 $this->assertEquals($skin->getName() .
" inject", $skin_copy->getName());
283 $this->assertEquals(
"0.1", $skin_copy->getVersion());
288 $this->markTestSkipped(
'Unzipping is not possible due to missing dependencies');
290 if (!defined(
'PATH_TO_ZIP')) {
291 if (file_exists(
"ilias.ini.php")) {
292 $ini = parse_ini_file(
"ilias.ini.php",
true);
293 define(
'PATH_TO_ZIP',
$ini[
'tools'][
'zip']);
294 } elseif (is_executable(
"/usr/bin/zip")) {
295 define(
'PATH_TO_ZIP',
"/usr/bin/zip");
297 define(
'PATH_TO_ZIP',
"");
301 if (!defined(
'PATH_TO_UNZIP')) {
302 if (file_exists(
"ilias.ini.php")) {
303 $ini = parse_ini_file(
"ilias.ini.php",
true);
304 define(
'PATH_TO_UNZIP',
$ini[
'tools'][
'unzip']);
305 } elseif (is_executable(
"/usr/bin/unzip")) {
306 define(
'PATH_TO_UNZIP',
"/usr/bin/unzip");
308 define(
'PATH_TO_UNZIP',
"");
313 if (PATH_TO_UNZIP !==
"" && PATH_TO_ZIP !==
"") {
317 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
320 $skin_copy = $container_import->getSkin();
322 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
323 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId()));
324 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1image"));
325 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1sound"));
326 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1font"));
327 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.css"));
328 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.less"));
329 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css-variables.less"));
331 $this->markTestIncomplete(
'No unzip has been detected on the system');
ilSkinXml holds an manages the basic data of a skin as provide by the template of the skin...
testCopySkinWithInjectedName()
testUpdateSkinNoIdChange()
static recursiveRemoveDir($dir)
Recursive delete of a folder.
testUpdateSkinWithChangedID()
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...
Used to stack messages to be shown to the user.
static xCopy($src, $dest)
Recursive copy of a folder.