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 $this->save_dic =
$DIC;
49 if(file_exists(
"ilias.ini.php")){
50 $ini = parse_ini_file(
"ilias.ini.php",
true);
51 define(
'PATH_TO_LESSC',
$ini[
'tools'][
'lessc']);
53 define(
'PATH_TO_LESSC',
"");
57 $this->skin =
new ilSkinXML(
"skin1",
"skin 1");
60 $this->style1->setCssFile(
"style1css");
61 $this->style1->setImageDirectory(
"style1image");
62 $this->style1->setSoundDirectory(
"style1sound");
63 $this->style1->setFontDirectory(
"style1font");
66 $this->style2->setCssFile(
"style2css");
67 $this->style2->setImageDirectory(
"style2image");
68 $this->style2->setSoundDirectory(
"style2sound");
69 $this->style2->setFontDirectory(
"style2font");
73 mkdir($this->system_style_config->test_skin_temp_path);
86 $this->assertEquals($container->getSkin()->getId(), $this->skin->getId());
87 $this->assertEquals($container->getSkin()->getName(), $this->skin->getName());
89 $this->assertEquals($container->getSkin()->getStyle($this->style1->getId()), $this->style1);
90 $this->assertEquals($container->getSkin()->getStyle($this->style2->getId()), $this->style2);
96 $container->getSkin()->setId(
"newSkin");
99 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().
"newSkin"));
100 $container->delete();
101 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().
"newSkin"));
106 $old_skin = clone $container->getSkin();
107 $container->getSkin()->setId(
"newSkin2");
108 $container->updateSkin($old_skin);
109 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().
"newSkin2"));
110 $old_skin = clone $container->getSkin();
111 $container->getSkin()->setId($this->skin->getId());
112 $container->updateSkin($old_skin);
113 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().
"newSkin2"));
118 $new_style->setCssFile(
"style1new");
119 $new_style->setImageDirectory(
"style1newimage");
120 $new_style->setSoundDirectory(
"style1newsound");
121 $new_style->setFontDirectory(
"style1newfont");
125 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1image"));
126 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1sound"));
127 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1font"));
128 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.css"));
129 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.less"));
130 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css-variables.less"));
132 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newimage"));
133 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newsound"));
134 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newfont"));
135 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new.css"));
136 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new.less"));
137 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new-variables.less"));
139 $container->addStyle($new_style);
141 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1image"));
142 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1sound"));
143 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1font"));
144 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.css"));
145 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.less"));
146 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css-variables.less"));
148 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newimage"));
149 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newsound"));
150 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newfont"));
151 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new.css"));
152 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new.less"));
153 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new-variables.less"));
159 $container->deleteStyle($this->style1);
161 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1image"));
162 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1sound"));
163 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1font"));
164 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.css"));
165 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.less"));
166 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css-variables.less"));
168 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style2image"));
169 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style2sound"));
170 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style2font"));
171 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style2css.css"));
172 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style2css.less"));
173 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style2css-variables.less"));
178 $skin = $container->getSkin();
180 $old_style = clone $skin->getStyle($this->style1->getId());
181 $new_style = $skin->getStyle($this->style1->getId());
183 $new_style->setId(
"style1new");
184 $new_style->setName(
"new Style");
185 $new_style->setCssFile(
"style1new");
186 $new_style->setImageDirectory(
"style1newimage");
187 $new_style->setSoundDirectory(
"style1newsound");
188 $new_style->setFontDirectory(
"style1newfont");
190 $container->updateStyle($new_style->getId(),$old_style);
192 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1image"));
193 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1sound"));
194 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1font"));
195 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.css"));
196 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css.less"));
197 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1css-variables.less"));
199 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newimage"));
200 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newsound"));
201 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1newfont"));
202 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new.css"));
203 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new.less"));
204 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$this->skin->getId().
"/style1new-variables.less"));
209 $skin = $container->getSkin();
211 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId()));
212 $container->delete();
213 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId()));
218 $skin = $container->getSkin();
220 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId().
"Copy"));
222 $container_copy = $container->copy();
223 $skin_copy = $container_copy->getSkin();
225 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId().
"Copy"));
226 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId()));
227 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1image"));
228 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1sound"));
229 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1font"));
230 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1css.css"));
231 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1css.less"));
232 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1css-variables.less"));
237 if(file_exists(
"ilias.ini.php")){
238 $ini = parse_ini_file(
"ilias.ini.php",
true);
239 define(
'PATH_TO_ZIP',
$ini[
'tools'][
'zip']);
241 define(
'PATH_TO_ZIP',
"");
246 if(file_exists(
"ilias.ini.php")) {
247 $ini = parse_ini_file(
"ilias.ini.php",
true);
248 define(
'PATH_TO_UNZIP',
$ini[
'tools'][
'unzip']);
250 define(
'PATH_TO_UNZIP',
"");
255 if(PATH_TO_UNZIP !=
""){
257 $skin = $container->getSkin();
259 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId().
"Copy"));
261 $container_import = $container->import($container->createTempZip(),$this->skin->getId().
".zip",null,
$this->system_style_config,
false);
262 $skin_copy = $container_import->getSkin();
264 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId().
"Copy"));
265 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId()));
266 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1image"));
267 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1sound"));
268 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1font"));
269 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1css.css"));
270 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1css.less"));
271 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath().$skin_copy->getId().
"/style1css-variables.less"));
273 $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.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static xCopy($src, $dest)
Recursive copy of a folder.