ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSystemStyleSkinContainerTest Class Reference
+ Inheritance diagram for ilSystemStyleSkinContainerTest:
+ Collaboration diagram for ilSystemStyleSkinContainerTest:

Public Member Functions

 testGenerateFromId ()
 
 testCreateDelete ()
 
 testUpdateSkin ()
 
 testAddStyle ()
 
 testDeleteStyle ()
 
 testUpdateStyle ()
 
 testDeleteSkin ()
 
 testCopySkin ()
 
 testImportSkin ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $skin
 
 $style1 = null
 
 $style2 = null
 
 $system_style_config
 
 $save_dic = null
 

Detailed Description

Member Function Documentation

◆ setUp()

ilSystemStyleSkinContainerTest::setUp ( )
protected

Definition at line 42 of file ilSystemStyleSkinContainerTest.php.

42 {
43 global $DIC;
44
45 $this->save_dic = $DIC;
47
48 if(!defined('PATH_TO_LESSC')){
49 if(file_exists("ilias.ini.php")){
50 $ini = parse_ini_file("ilias.ini.php",true);
51 define('PATH_TO_LESSC', $ini['tools']['lessc']);
52 }else{
53 define('PATH_TO_LESSC', "");
54 }
55 }
56
57 $this->skin = new ilSkinXML("skin1", "skin 1");
58
59 $this->style1 = new ilSkinStyleXML("style1", "Style 1");
60 $this->style1->setCssFile("style1css");
61 $this->style1->setImageDirectory("style1image");
62 $this->style1->setSoundDirectory("style1sound");
63 $this->style1->setFontDirectory("style1font");
64
65 $this->style2 = new ilSkinStyleXML("style2", "Style 2");
66 $this->style2->setCssFile("style2css");
67 $this->style2->setImageDirectory("style2image");
68 $this->style2->setSoundDirectory("style2sound");
69 $this->style2->setFontDirectory("style2font");
70
71 $this->system_style_config = new ilSystemStyleConfigMock();
72
73 mkdir($this->system_style_config->test_skin_temp_path);
74 ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path,$this->system_style_config->test_skin_temp_path);
75 }
ilSkinXml holds an manages the basic data of a skin as provide by the template of the skin.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Class ilLanguageMock.
static xCopy($src, $dest)
Recursive copy of a folder.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
$ini
Definition: raiseError.php:4
global $DIC

References $DIC, $ini, defined, and ilSystemStyleSkinContainer\xCopy().

+ Here is the call graph for this function:

◆ tearDown()

ilSystemStyleSkinContainerTest::tearDown ( )
protected

Definition at line 77 of file ilSystemStyleSkinContainerTest.php.

77 {
78 global $DIC;
80
81 ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
82 }
static recursiveRemoveDir($dir)
Recursive delete of a folder.

References $DIC, $save_dic, and ilSystemStyleSkinContainer\recursiveRemoveDir().

+ Here is the call graph for this function:

◆ testAddStyle()

ilSystemStyleSkinContainerTest::testAddStyle ( )

Definition at line 116 of file ilSystemStyleSkinContainerTest.php.

116 {
117 $new_style = new ilSkinStyleXML("style1new","new Style");
118 $new_style->setCssFile("style1new");
119 $new_style->setImageDirectory("style1newimage");
120 $new_style->setSoundDirectory("style1newsound");
121 $new_style->setFontDirectory("style1newfont");
122
123 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
124
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"));
131
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"));
138
139 $container->addStyle($new_style);
140
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"));
147
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"));
154 }
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.

References ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testCopySkin()

ilSystemStyleSkinContainerTest::testCopySkin ( )

Definition at line 216 of file ilSystemStyleSkinContainerTest.php.

216 {
217 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
218 $skin = $container->getSkin();
219
220 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId()."Copy"));
221
222 $container_copy = $container->copy();
223 $skin_copy = $container_copy->getSkin();
224
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"));
233 }

References $skin, and ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testCreateDelete()

ilSystemStyleSkinContainerTest::testCreateDelete ( )

Definition at line 93 of file ilSystemStyleSkinContainerTest.php.

93 {
94 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
95
96 $container->getSkin()->setId("newSkin");
97 $container->create(new ilSystemStyleMessageStack());
98
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"));
102 }
Used to stack messages to be shown to the user.

References ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testDeleteSkin()

ilSystemStyleSkinContainerTest::testDeleteSkin ( )

Definition at line 207 of file ilSystemStyleSkinContainerTest.php.

207 {
208 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
209 $skin = $container->getSkin();
210
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()));
214 }

References $skin, and ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testDeleteStyle()

ilSystemStyleSkinContainerTest::testDeleteStyle ( )

Definition at line 156 of file ilSystemStyleSkinContainerTest.php.

156 {
157 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
158
159 $container->deleteStyle($this->style1);
160
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"));
167
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"));
174 }

References ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testGenerateFromId()

ilSystemStyleSkinContainerTest::testGenerateFromId ( )

Definition at line 84 of file ilSystemStyleSkinContainerTest.php.

84 {
85 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
86 $this->assertEquals($container->getSkin()->getId(), $this->skin->getId());
87 $this->assertEquals($container->getSkin()->getName(), $this->skin->getName());
88
89 $this->assertEquals($container->getSkin()->getStyle($this->style1->getId()), $this->style1);
90 $this->assertEquals($container->getSkin()->getStyle($this->style2->getId()), $this->style2);
91 }

References ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testImportSkin()

ilSystemStyleSkinContainerTest::testImportSkin ( )

Definition at line 235 of file ilSystemStyleSkinContainerTest.php.

235 {
236 if(!defined('PATH_TO_ZIP')){
237 if(file_exists("ilias.ini.php")){
238 $ini = parse_ini_file("ilias.ini.php",true);
239 define('PATH_TO_ZIP', $ini['tools']['zip']);
240 }else{
241 define('PATH_TO_ZIP', "");
242 }
243 }
244
245 if(!defined('PATH_TO_UNZIP')){
246 if(file_exists("ilias.ini.php")) {
247 $ini = parse_ini_file("ilias.ini.php",true);
248 define('PATH_TO_UNZIP', $ini['tools']['unzip']);
249 }else{
250 define('PATH_TO_UNZIP', "");
251 }
252 }
253
254 //Only perform this test, if an unzip path has been found.
255 if(PATH_TO_UNZIP != ""){
256 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
257 $skin = $container->getSkin();
258
259 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath().$skin->getId()."Copy"));
260
261 $container_import = $container->import($container->createTempZip(),$this->skin->getId().".zip",null,$this->system_style_config,false);
262 $skin_copy = $container_import->getSkin();
263
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"));
272 }else{
273 $this->markTestIncomplete('No unzip has been detected on the system');
274 }
275 }

References $ini, $skin, defined, and ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testUpdateSkin()

ilSystemStyleSkinContainerTest::testUpdateSkin ( )

Definition at line 104 of file ilSystemStyleSkinContainerTest.php.

104 {
105 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
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"));
114 }

References ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

◆ testUpdateStyle()

ilSystemStyleSkinContainerTest::testUpdateStyle ( )

Definition at line 176 of file ilSystemStyleSkinContainerTest.php.

176 {
177 $container = ilSystemStyleSkinContainer::generateFromId($this->skin->getId(),null,$this->system_style_config);
178 $skin = $container->getSkin();
179
180 $old_style = clone $skin->getStyle($this->style1->getId());
181 $new_style = $skin->getStyle($this->style1->getId());
182
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");
189
190 $container->updateStyle($new_style->getId(),$old_style);
191
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"));
198
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"));
205 }

References $skin, and ilSystemStyleSkinContainer\generateFromId().

+ Here is the call graph for this function:

Field Documentation

◆ $save_dic

ilSystemStyleSkinContainerTest::$save_dic = null
protected

Definition at line 40 of file ilSystemStyleSkinContainerTest.php.

Referenced by tearDown().

◆ $skin

ilSystemStyleSkinContainerTest::$skin
protected

◆ $style1

ilSystemStyleSkinContainerTest::$style1 = null
protected

Definition at line 28 of file ilSystemStyleSkinContainerTest.php.

◆ $style2

ilSystemStyleSkinContainerTest::$style2 = null
protected

Definition at line 33 of file ilSystemStyleSkinContainerTest.php.

◆ $system_style_config

ilSystemStyleSkinContainerTest::$system_style_config
protected

Definition at line 38 of file ilSystemStyleSkinContainerTest.php.


The documentation for this class was generated from the following file: