ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemStyleIconFolderTest Class Reference
+ Inheritance diagram for ilSystemStyleIconFolderTest:
+ Collaboration diagram for ilSystemStyleIconFolderTest:

Public Member Functions

 testConstruct ()
 
 testSetPath ()
 
 testReadRecursiveCount ()
 
 testFolderDoesNotExist ()
 
 testFolderGetIconByName ()
 
 testFolderGetIconByPath ()
 
 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 49 of file ilSystemStyleIconFolderTest.php.

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

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

◆ tearDown()

ilSystemStyleIconFolderTest::tearDown ( )
protected

Definition at line 65 of file ilSystemStyleIconFolderTest.php.

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

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

◆ testConstruct()

ilSystemStyleIconFolderTest::testConstruct ( )

Definition at line 73 of file ilSystemStyleIconFolderTest.php.

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

◆ testExtractChangeColors()

ilSystemStyleIconFolderTest::testExtractChangeColors ( )

Definition at line 214 of file ilSystemStyleIconFolderTest.php.

215  {
216  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
217  $folder1->changeIconColors(["505050" => "555555"]);
218 
219  $folder2 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
220 
221  $expected_color_set = new ilSystemStyleIconColorSet();
222  $color1 = new ilSystemStyleIconColor("id_555555", "555555", "555555", "555555");
223  $color2 = new ilSystemStyleIconColor("id_6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
224  $color3 = new ilSystemStyleIconColor("id_838383", "838383", "838383", "838383");
225  $color4 = new ilSystemStyleIconColor("id_8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
226  $color5 = new ilSystemStyleIconColor("id_303030", "303030", "303030", "303030");
227  $color6 = new ilSystemStyleIconColor("id_404040", "404040", "404040", "404040");
228  $color7 = new ilSystemStyleIconColor("id_000", "000", "000", "000");
229 
230  $expected_color_set->addColor($color2);
231  $expected_color_set->addColor($color3);
232  $expected_color_set->addColor($color4);
233  $expected_color_set->addColor($color5);
234  $expected_color_set->addColor($color6);
235  $expected_color_set->addColor($color1);
236  $expected_color_set->addColor($color7);
237 
238  $this->assertEquals($expected_color_set, $folder2->getColorSet());
239  }
Abstracts a folder containing a set of icons.

◆ testExtractColorset()

ilSystemStyleIconFolderTest::testExtractColorset ( )

Definition at line 190 of file ilSystemStyleIconFolderTest.php.

191  {
192  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
193 
194  $expected_color_set = new ilSystemStyleIconColorSet();
195  $color1 = new ilSystemStyleIconColor("id_505050", "505050", "505050", "505050");
196  $color2 = new ilSystemStyleIconColor("id_6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
197  $color3 = new ilSystemStyleIconColor("id_838383", "838383", "838383", "838383");
198  $color4 = new ilSystemStyleIconColor("id_8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
199  $color5 = new ilSystemStyleIconColor("id_303030", "303030", "303030", "303030");
200  $color6 = new ilSystemStyleIconColor("id_404040", "404040", "404040", "404040");
201  $color7 = new ilSystemStyleIconColor("id_000", "000", "000", "000");
202 
203  $expected_color_set->addColor($color1);
204  $expected_color_set->addColor($color2);
205  $expected_color_set->addColor($color3);
206  $expected_color_set->addColor($color4);
207  $expected_color_set->addColor($color5);
208  $expected_color_set->addColor($color6);
209  $expected_color_set->addColor($color7);
210 
211  $this->assertEquals($expected_color_set, $folder->getColorSet());
212  }
Abstracts a folder containing a set of icons.

◆ testFolderDoesNotExist()

ilSystemStyleIconFolderTest::testFolderDoesNotExist ( )

Definition at line 95 of file ilSystemStyleIconFolderTest.php.

References Vendor\Package\$e, and ilSystemStyleIconException\IMAGES_FOLDER_DOES_NOT_EXIST.

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

◆ testFolderGetIconByName()

ilSystemStyleIconFolderTest::testFolderGetIconByName ( )

Definition at line 105 of file ilSystemStyleIconFolderTest.php.

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

◆ testFolderGetIconByPath()

ilSystemStyleIconFolderTest::testFolderGetIconByPath ( )

Definition at line 115 of file ilSystemStyleIconFolderTest.php.

116  {
117  $style_path = $this->container->getImagesSkinPath($this->style->getId());
118 
119  $path1 = $style_path . "/test_image_1.svg";
120  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
121  $folder = new ilSystemStyleIconFolder($style_path);
122  $this->assertEquals($icon1, $folder->getIconByPath($path1));
123  }
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 241 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 
247  $path1 = $style_path . "/test_image_1.svg";
248  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
249  $icon1->getColorSet();
250 
251  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
252  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
253  $icon2->getColorSet();
254 
255  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
256  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
257  $icon3->getColorSet();
258 
259  $expected_icons_usages = [$icon2,$icon3,$icon1];
260 
261  $this->assertEquals($expected_icons_usages, $folder1->getUsagesOfColor("id_6B6B6B"));
262  }
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 264 of file ilSystemStyleIconFolderTest.php.

265  {
266  $style_path = $this->container->getImagesSkinPath($this->style->getId());
267 
268  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
269  $folder1->changeIconColors(["6B6B6B" => "7B6B6B"]);
270 
271  $folder2 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
272 
273  $path1 = $style_path . "/test_image_1.svg";
274  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
275  $icon1->getColorSet();
276 
277  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
278  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
279  $icon2->getColorSet();
280 
281  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
282  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
283  $icon3->getColorSet();
284 
285  $expected_icons_usages = [$icon2,$icon3,$icon1];
286 
287  $this->assertEquals($expected_icons_usages, $folder2->getUsagesOfColor("id_7B6B6B"));
288  $this->assertEquals([], $folder2->getUsagesOfColor("id_6B6B6B"));
289  }
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 291 of file ilSystemStyleIconFolderTest.php.

292  {
293  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
294 
295  $this->assertEquals(
296  'sub_test_image_1; sub_test_image_2; test_image_1; ',
297  $folder1->getUsagesOfColorAsString("id_6B6B6B")
298  );
299  }
Abstracts a folder containing a set of icons.

◆ testIconDoesNotExist()

ilSystemStyleIconFolderTest::testIconDoesNotExist ( )

Definition at line 125 of file ilSystemStyleIconFolderTest.php.

References Vendor\Package\$e, and ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

126  {
127  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
128 
129  try {
130  $folder->getIconByName("doesNotExist.svg");
131  $this->assertTrue(false);
132  } catch (ilSystemStyleIconException $e) {
133  $this->assertEquals(ilSystemStyleIconException::ICON_DOES_NOT_EXIST, $e->getCode());
134  }
135  }
Class for advanced editing exception handling in ILIAS.
Abstracts a folder containing a set of icons.

◆ testReadRecursiveAndSortByFolder()

ilSystemStyleIconFolderTest::testReadRecursiveAndSortByFolder ( )

Definition at line 162 of file ilSystemStyleIconFolderTest.php.

163  {
164  $style_path = $this->container->getImagesSkinPath($this->style->getId());
165 
166  $path1 = $style_path . "/test_image_1.svg";
167  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
168 
169  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
170  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
171 
172  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
173  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
174 
175  $path4 = $style_path . "/nonsvg.png";
176  $icon4 = new ilSystemStyleIcon("nonsvg.png", $path4, "png");
177 
178  $path5 = $style_path . "/icon_accs.svg";
179  $icon5 = new ilSystemStyleIcon("icon_accs.svg", $path5, "svg");
180 
181  $expected_icons = [
182  $style_path => [$icon5,$icon1,$icon4],
183  $style_path . "/image_subfolder" => [$icon2,$icon3],
184  ];
185 
186  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
187  $this->assertEquals($expected_icons, $folder->getIconsSortedByFolder());
188  }
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 137 of file ilSystemStyleIconFolderTest.php.

138  {
139  $style_path = $this->container->getImagesSkinPath($this->style->getId());
140 
141  $path1 = $style_path . "/test_image_1.svg";
142  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
143 
144  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
145  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
146 
147  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
148  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
149 
150  $path4 = $style_path . "/nonsvg.png";
151  $icon4 = new ilSystemStyleIcon("nonsvg.png", $path4, "png");
152 
153  $path5 = $style_path . "/icon_accs.svg";
154  $icon5 = new ilSystemStyleIcon("icon_accs.svg", $path5, "svg");
155 
156  $expected_icons = [$icon5,$icon2,$icon3,$icon1,$icon4];
157 
158  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
159  $this->assertEquals($expected_icons, $folder->getIcons());
160  }
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 89 of file ilSystemStyleIconFolderTest.php.

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

◆ testSetPath()

ilSystemStyleIconFolderTest::testSetPath ( )

Definition at line 80 of file ilSystemStyleIconFolderTest.php.

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

Field Documentation

◆ $container

ilSystemStyleIconFolderTest::$container
protected

Definition at line 30 of file ilSystemStyleIconFolderTest.php.

◆ $icon_name

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

Definition at line 40 of file ilSystemStyleIconFolderTest.php.

◆ $icon_type

ilSystemStyleIconFolderTest::$icon_type = "svg"
protected

Definition at line 45 of file ilSystemStyleIconFolderTest.php.

◆ $save_dic

ilSystemStyleIconFolderTest::$save_dic = null
protected

Definition at line 47 of file ilSystemStyleIconFolderTest.php.

Referenced by tearDown().

◆ $style

ilSystemStyleIconFolderTest::$style
protected

Definition at line 35 of file ilSystemStyleIconFolderTest.php.

◆ $system_style_config

ilSystemStyleIconFolderTest::$system_style_config
protected

Definition at line 25 of file ilSystemStyleIconFolderTest.php.


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