3 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
4 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinXML.php");
5 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleSkinContainer.php");
6 include_once(
"Services/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php");
7 include_once(
"Services/Style/System/test/fixtures/mocks/ilSystemStyleDICMock.php");
9 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleMessageStack.php");
10 include_once(
"Services/Utilities/classes/class.ilUtil.php");
45 protected function setUp() : void
49 $this->save_dic =
$DIC;
52 if (!defined(
'PATH_TO_LESSC')) {
53 if (file_exists(
"ilias.ini.php")) {
54 $ini = parse_ini_file(
"ilias.ini.php",
true);
55 define(
'PATH_TO_LESSC',
$ini[
'tools'][
'lessc']);
57 define(
'PATH_TO_LESSC',
"");
61 $this->skin =
new ilSkinXML(
"skin1",
"skin 1");
64 $this->style1->setCssFile(
"style1css");
65 $this->style1->setImageDirectory(
"style1image");
66 $this->style1->setSoundDirectory(
"style1sound");
67 $this->style1->setFontDirectory(
"style1font");
70 $this->style2->setCssFile(
"style2css");
71 $this->style2->setImageDirectory(
"style2image");
72 $this->style2->setSoundDirectory(
"style2sound");
73 $this->style2->setFontDirectory(
"style2font");
77 mkdir($this->system_style_config->test_skin_temp_path);
92 $this->assertEquals(
$container->getSkin()->getId(), $this->skin->getId());
93 $this->assertEquals(
$container->getSkin()->getName(), $this->skin->getName());
95 $this->assertEquals(
$container->getSkin()->getStyle($this->style1->getId()), $this->style1);
96 $this->assertEquals(
$container->getSkin()->getStyle($this->style2->getId()), $this->style2);
106 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin"));
108 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin"));
117 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin2"));
119 $container->getSkin()->setId($this->skin->getId());
121 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() .
"newSkin2"));
127 $new_style->setCssFile(
"style1new");
128 $new_style->setImageDirectory(
"style1newimage");
129 $new_style->setSoundDirectory(
"style1newsound");
130 $new_style->setFontDirectory(
"style1newfont");
134 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
135 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
136 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
137 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
138 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
139 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
141 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newimage"));
142 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newsound"));
143 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newfont"));
144 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.css"));
145 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.less"));
146 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new-variables.less"));
150 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
151 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
152 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
153 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
154 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
155 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
157 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newimage"));
158 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newsound"));
159 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newfont"));
160 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.css"));
161 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.less"));
162 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new-variables.less"));
171 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
172 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
173 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
174 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
175 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
176 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
178 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2image"));
179 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2sound"));
180 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2font"));
181 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2css.css"));
182 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2css.less"));
183 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style2css-variables.less"));
191 $old_style = clone $skin->getStyle($this->style1->getId());
192 $new_style = $skin->getStyle($this->style1->getId());
194 $new_style->setId(
"style1new");
195 $new_style->setName(
"new Style");
196 $new_style->setCssFile(
"style1new");
197 $new_style->setImageDirectory(
"style1newimage");
198 $new_style->setSoundDirectory(
"style1newsound");
199 $new_style->setFontDirectory(
"style1newfont");
201 $container->updateStyle($new_style->getId(), $old_style);
203 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1image"));
204 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1sound"));
205 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1font"));
206 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.css"));
207 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css.less"));
208 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1css-variables.less"));
210 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newimage"));
211 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newsound"));
212 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1newfont"));
213 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.css"));
214 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new.less"));
215 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() .
"/style1new-variables.less"));
223 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId()));
225 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId()));
233 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
236 $skin_copy = $container_copy->getSkin();
238 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
239 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId()));
240 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1image"));
241 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1sound"));
242 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1font"));
243 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.css"));
244 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.less"));
245 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css-variables.less"));
250 if (!defined(
'PATH_TO_ZIP')) {
251 if (file_exists(
"ilias.ini.php")) {
252 $ini = parse_ini_file(
"ilias.ini.php",
true);
253 define(
'PATH_TO_ZIP',
$ini[
'tools'][
'zip']);
254 } elseif (is_executable(
"/usr/bin/zip")) {
255 define(
'PATH_TO_ZIP',
"/usr/bin/zip");
257 define(
'PATH_TO_ZIP',
"");
261 if (!defined(
'PATH_TO_UNZIP')) {
262 if (file_exists(
"ilias.ini.php")) {
263 $ini = parse_ini_file(
"ilias.ini.php",
true);
264 define(
'PATH_TO_UNZIP',
$ini[
'tools'][
'unzip']);
265 } elseif (is_executable(
"/usr/bin/unzip")) {
266 define(
'PATH_TO_UNZIP',
"/usr/bin/unzip");
268 define(
'PATH_TO_UNZIP',
"");
273 if (PATH_TO_UNZIP !=
"") {
277 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
280 $skin_copy = $container_import->getSkin();
282 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() .
"Copy"));
283 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId()));
284 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1image"));
285 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1sound"));
286 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1font"));
287 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.css"));
288 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css.less"));
289 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() .
"/style1css-variables.less"));
291 $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...
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...
Used to stack messages to be shown to the user.
static xCopy($src, $dest)
Recursive copy of a folder.