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

Public Member Functions

 testConstruct ()
 
 testSetPath ()
 
 testReadRecursiveCount ()
 
 testFolderDoesNotExist ()
 
 testFolderGetIcon ()
 
 testIconDoesNotExist ()
 
 testReadRecursiveAndSortByName ()
 
 testReadRecursiveAndSortByFolder ()
 
 testExtractColorset ()
 
 testExtractChangeColors ()
 
 testGetUsages ()
 
 testGetUsagesAfterChangeColor ()
 
 testGetUsagesAsString ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $system_style_config
 
 $container
 
 $style
 
 $icon_name = "test_image_1.svg"
 
 $icon_type = "svg"
 
 $save_dic = null
 

Detailed Description

Member Function Documentation

◆ setUp()

ilSystemStyleIconFolderTest::setUp ( )
protected

Definition at line 48 of file ilSystemStyleIconFolderTest.php.

References $DIC, ilSystemStyleSkinContainer\generateFromId(), and ilSystemStyleSkinContainer\xCopy().

49  {
50  global $DIC;
51 
52  $this->save_dic = $DIC;
53  $DIC = new ilSystemStyleDICMock();
54 
55  $this->system_style_config = new ilSystemStyleConfigMock();
56 
57  mkdir($this->system_style_config->test_skin_temp_path);
58  ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path, $this->system_style_config->test_skin_temp_path);
59 
60  $this->container = ilSystemStyleSkinContainer::generateFromId("skin1", null, $this->system_style_config);
61  $this->style = $this->container->getSkin()->getStyle("style1");
62  }
Class ilLanguageMock.
"color:#CC0000 style
Definition: example_001.php:92
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...
global $DIC
static xCopy($src, $dest)
Recursive copy of a folder.
+ Here is the call graph for this function:

◆ tearDown()

ilSystemStyleIconFolderTest::tearDown ( )
protected

Definition at line 64 of file ilSystemStyleIconFolderTest.php.

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

65  {
66  global $DIC;
67  $DIC = $this->save_dic;
68 
69  ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
70  }
static recursiveRemoveDir($dir)
Recursive delete of a folder.
global $DIC
+ Here is the call graph for this function:

◆ testConstruct()

ilSystemStyleIconFolderTest::testConstruct ( )

Definition at line 72 of file ilSystemStyleIconFolderTest.php.

73  {
74  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
75 
76  $this->assertEquals($this->container->getImagesSkinPath($this->style->getId()),$folder->getPath());
77  }
Abstracts a folder containing a set of icons.

◆ testExtractChangeColors()

ilSystemStyleIconFolderTest::testExtractChangeColors ( )

Definition at line 196 of file ilSystemStyleIconFolderTest.php.

196  {
197  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
198  $folder1->changeIconColors(["505050"=>"555555"]);
199 
200  $folder2 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
201 
202  $expected_color_set = new ilSystemStyleIconColorSet();
203  $color1 = new ilSystemStyleIconColor("555555", "555555", "555555", "555555");
204  $color2 = new ilSystemStyleIconColor("6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
205  $color3 = new ilSystemStyleIconColor("838383", "838383", "838383", "838383");
206  $color4 = new ilSystemStyleIconColor("8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
207  $color5 = new ilSystemStyleIconColor("303030", "303030", "303030", "303030");
208  $color6 = new ilSystemStyleIconColor("404040", "404040", "404040", "404040");
209 
210  $expected_color_set->addColor($color2);
211  $expected_color_set->addColor($color3);
212  $expected_color_set->addColor($color4);
213  $expected_color_set->addColor($color5);
214  $expected_color_set->addColor($color6);
215  $expected_color_set->addColor($color1);
216 
217  $this->assertEquals($expected_color_set,$folder2->getColorSet());
218  }
Abstracts a folder containing a set of icons.

◆ testExtractColorset()

ilSystemStyleIconFolderTest::testExtractColorset ( )

Definition at line 174 of file ilSystemStyleIconFolderTest.php.

175  {
176  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
177 
178  $expected_color_set = new ilSystemStyleIconColorSet();
179  $color1 = new ilSystemStyleIconColor("505050", "505050", "505050", "505050");
180  $color2 = new ilSystemStyleIconColor("6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
181  $color3 = new ilSystemStyleIconColor("838383", "838383", "838383", "838383");
182  $color4 = new ilSystemStyleIconColor("8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
183  $color5 = new ilSystemStyleIconColor("303030", "303030", "303030", "303030");
184  $color6 = new ilSystemStyleIconColor("404040", "404040", "404040", "404040");
185 
186  $expected_color_set->addColor($color1);
187  $expected_color_set->addColor($color2);
188  $expected_color_set->addColor($color3);
189  $expected_color_set->addColor($color4);
190  $expected_color_set->addColor($color5);
191  $expected_color_set->addColor($color6);
192 
193  $this->assertEquals($expected_color_set, $folder->getColorSet());
194  }
Abstracts a folder containing a set of icons.

◆ testFolderDoesNotExist()

ilSystemStyleIconFolderTest::testFolderDoesNotExist ( )

Definition at line 94 of file ilSystemStyleIconFolderTest.php.

References ilSystemStyleIconException\IMAGES_FOLDER_DOES_NOT_EXIST.

95  {
96  try{
97  new ilSystemStyleIconFolder("Does not exist");
98  $this->assertTrue(false);
99  }catch(ilSystemStyleIconException $e){
100  $this->assertEquals(ilSystemStyleIconException::IMAGES_FOLDER_DOES_NOT_EXIST,$e->getCode());
101  }
102  }
Class for advanced editing exception handling in ILIAS.
Abstracts a folder containing a set of icons.

◆ testFolderGetIcon()

ilSystemStyleIconFolderTest::testFolderGetIcon ( )

Definition at line 104 of file ilSystemStyleIconFolderTest.php.

105  {
106  $style_path = $this->container->getImagesSkinPath($this->style->getId());
107 
108  $path1 = $style_path . "/test_image_1.svg";
109  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
110  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
111  $this->assertEquals($icon1,$folder->getIconByName("test_image_1.svg"));
112 
113  }
"color:#CC0000 style
Definition: example_001.php:92
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
Abstracts a folder containing a set of icons.

◆ testGetUsages()

ilSystemStyleIconFolderTest::testGetUsages ( )

Definition at line 220 of file ilSystemStyleIconFolderTest.php.

220  {
221  $style_path = $this->container->getImagesSkinPath($this->style->getId());
222 
223  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
224 
225  $path1 = $style_path . "/test_image_1.svg";
226  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
227  $icon1->getColorSet();
228 
229  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
230  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
231  $icon2->getColorSet();
232 
233  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
234  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
235  $icon3->getColorSet();
236 
237  $expected_icons_usages = [$icon2,$icon3,$icon1];
238 
239  $this->assertEquals($expected_icons_usages,$folder1->getUsagesOfColor("6B6B6B"));
240  }
"color:#CC0000 style
Definition: example_001.php:92
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
Abstracts a folder containing a set of icons.

◆ testGetUsagesAfterChangeColor()

ilSystemStyleIconFolderTest::testGetUsagesAfterChangeColor ( )

Definition at line 242 of file ilSystemStyleIconFolderTest.php.

242  {
243  $style_path = $this->container->getImagesSkinPath($this->style->getId());
244 
245  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
246  $folder1->changeIconColors(["6B6B6B"=>"7B6B6B"]);
247 
248  $folder2 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
249 
250  $path1 = $style_path . "/test_image_1.svg";
251  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
252  $icon1->getColorSet();
253 
254  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
255  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
256  $icon2->getColorSet();
257 
258  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
259  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
260  $icon3->getColorSet();
261 
262  $expected_icons_usages = [$icon2,$icon3,$icon1];
263 
264  $this->assertEquals($expected_icons_usages,$folder2->getUsagesOfColor("7B6B6B"));
265  $this->assertEquals([],$folder2->getUsagesOfColor("6B6B6B"));
266  }
"color:#CC0000 style
Definition: example_001.php:92
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
Abstracts a folder containing a set of icons.

◆ testGetUsagesAsString()

ilSystemStyleIconFolderTest::testGetUsagesAsString ( )

Definition at line 268 of file ilSystemStyleIconFolderTest.php.

268  {
269  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
270 
271  $this->assertEquals('sub_test_image_1; sub_test_image_2; test_image_1; ' ,
272  $folder1->getUsagesOfColorAsString("6B6B6B"));
273  }
Abstracts a folder containing a set of icons.

◆ testIconDoesNotExist()

ilSystemStyleIconFolderTest::testIconDoesNotExist ( )

Definition at line 115 of file ilSystemStyleIconFolderTest.php.

References ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

116  {
117  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
118 
119  try{
120  $folder->getIconByName("doesNotExist.svg");
121  $this->assertTrue(false);
122  }catch(ilSystemStyleIconException $e){
123  $this->assertEquals(ilSystemStyleIconException::ICON_DOES_NOT_EXIST,$e->getCode());
124  }
125  }
Class for advanced editing exception handling in ILIAS.
Abstracts a folder containing a set of icons.

◆ testReadRecursiveAndSortByFolder()

ilSystemStyleIconFolderTest::testReadRecursiveAndSortByFolder ( )

Definition at line 149 of file ilSystemStyleIconFolderTest.php.

150  {
151  $style_path = $this->container->getImagesSkinPath($this->style->getId());
152 
153  $path1 = $style_path. "/test_image_1.svg";
154  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
155 
156  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
157  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
158 
159  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
160  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
161 
162  $path4 = $style_path . "/nonsvg.png";
163  $icon4 = new ilSystemStyleIcon("nonsvg.png", $path4, "png");
164 
165  $expected_icons = [
166  $style_path => [$icon1,$icon4],
167  $style_path."/image_subfolder" => [$icon2,$icon3],
168  ];
169 
170  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
171  $this->assertEquals($expected_icons,$folder->getIconsSortedByFolder());
172  }
"color:#CC0000 style
Definition: example_001.php:92
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
Abstracts a folder containing a set of icons.

◆ testReadRecursiveAndSortByName()

ilSystemStyleIconFolderTest::testReadRecursiveAndSortByName ( )

Definition at line 127 of file ilSystemStyleIconFolderTest.php.

128  {
129  $style_path = $this->container->getImagesSkinPath($this->style->getId());
130 
131  $path1 = $style_path . "/test_image_1.svg";
132  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
133 
134  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
135  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
136 
137  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
138  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
139 
140  $path4 = $style_path . "/nonsvg.png";
141  $icon4 = new ilSystemStyleIcon("nonsvg.png", $path4, "png");
142 
143  $expected_icons = [$icon2,$icon3,$icon1,$icon4];
144 
145  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
146  $this->assertEquals($expected_icons,$folder->getIcons());
147  }
"color:#CC0000 style
Definition: example_001.php:92
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
Abstracts a folder containing a set of icons.

◆ testReadRecursiveCount()

ilSystemStyleIconFolderTest::testReadRecursiveCount ( )

Definition at line 88 of file ilSystemStyleIconFolderTest.php.

89  {
90  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
91  $this->assertEquals(4,count($folder->getIcons()));
92  }
Abstracts a folder containing a set of icons.

◆ testSetPath()

ilSystemStyleIconFolderTest::testSetPath ( )

Definition at line 79 of file ilSystemStyleIconFolderTest.php.

80  {
81  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
82  $folder->setPath("pathnew");
83 
84  $this->assertEquals("pathnew",$folder->getPath());
85  }
Abstracts a folder containing a set of icons.

Field Documentation

◆ $container

ilSystemStyleIconFolderTest::$container
protected

Definition at line 29 of file ilSystemStyleIconFolderTest.php.

◆ $icon_name

ilSystemStyleIconFolderTest::$icon_name = "test_image_1.svg"
protected

Definition at line 39 of file ilSystemStyleIconFolderTest.php.

◆ $icon_type

ilSystemStyleIconFolderTest::$icon_type = "svg"
protected

Definition at line 44 of file ilSystemStyleIconFolderTest.php.

◆ $save_dic

ilSystemStyleIconFolderTest::$save_dic = null
protected

Definition at line 46 of file ilSystemStyleIconFolderTest.php.

Referenced by tearDown().

◆ $style

ilSystemStyleIconFolderTest::$style
protected

Definition at line 34 of file ilSystemStyleIconFolderTest.php.

◆ $system_style_config

ilSystemStyleIconFolderTest::$system_style_config
protected

Definition at line 24 of file ilSystemStyleIconFolderTest.php.


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