ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.
global $DIC
Definition: saml.php:7
"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...
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  }
global $DIC
Definition: saml.php:7
static recursiveRemoveDir($dir)
Recursive delete of a folder.
+ 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 195 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 173 of file ilSystemStyleIconFolderTest.php.

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

221  {
222  $style_path = $this->container->getImagesSkinPath($this->style->getId());
223 
224  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
225 
226  $path1 = $style_path . "/test_image_1.svg";
227  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
228  $icon1->getColorSet();
229 
230  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
231  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
232  $icon2->getColorSet();
233 
234  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
235  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
236  $icon3->getColorSet();
237 
238  $expected_icons_usages = [$icon2,$icon3,$icon1];
239 
240  $this->assertEquals($expected_icons_usages, $folder1->getUsagesOfColor("6B6B6B"));
241  }
"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 243 of file ilSystemStyleIconFolderTest.php.

244  {
245  $style_path = $this->container->getImagesSkinPath($this->style->getId());
246 
247  $folder1 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
248  $folder1->changeIconColors(["6B6B6B"=>"7B6B6B"]);
249 
250  $folder2 = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
251 
252  $path1 = $style_path . "/test_image_1.svg";
253  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
254  $icon1->getColorSet();
255 
256  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
257  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
258  $icon2->getColorSet();
259 
260  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
261  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
262  $icon3->getColorSet();
263 
264  $expected_icons_usages = [$icon2,$icon3,$icon1];
265 
266  $this->assertEquals($expected_icons_usages, $folder2->getUsagesOfColor("7B6B6B"));
267  $this->assertEquals([], $folder2->getUsagesOfColor("6B6B6B"));
268  }
"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 270 of file ilSystemStyleIconFolderTest.php.

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

◆ testIconDoesNotExist()

ilSystemStyleIconFolderTest::testIconDoesNotExist ( )

Definition at line 114 of file ilSystemStyleIconFolderTest.php.

References ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

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

◆ testReadRecursiveAndSortByFolder()

ilSystemStyleIconFolderTest::testReadRecursiveAndSortByFolder ( )

Definition at line 148 of file ilSystemStyleIconFolderTest.php.

149  {
150  $style_path = $this->container->getImagesSkinPath($this->style->getId());
151 
152  $path1 = $style_path . "/test_image_1.svg";
153  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
154 
155  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
156  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
157 
158  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
159  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
160 
161  $path4 = $style_path . "/nonsvg.png";
162  $icon4 = new ilSystemStyleIcon("nonsvg.png", $path4, "png");
163 
164  $expected_icons = [
165  $style_path => [$icon1,$icon4],
166  $style_path . "/image_subfolder" => [$icon2,$icon3],
167  ];
168 
169  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
170  $this->assertEquals($expected_icons, $folder->getIconsSortedByFolder());
171  }
"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 126 of file ilSystemStyleIconFolderTest.php.

127  {
128  $style_path = $this->container->getImagesSkinPath($this->style->getId());
129 
130  $path1 = $style_path . "/test_image_1.svg";
131  $icon1 = new ilSystemStyleIcon("test_image_1.svg", $path1, "svg");
132 
133  $path2 = $style_path . "/image_subfolder/sub_test_image_1.svg";
134  $icon2 = new ilSystemStyleIcon("sub_test_image_1.svg", $path2, "svg");
135 
136  $path3 = $style_path . "/image_subfolder/sub_test_image_2.svg";
137  $icon3 = new ilSystemStyleIcon("sub_test_image_2.svg", $path3, "svg");
138 
139  $path4 = $style_path . "/nonsvg.png";
140  $icon4 = new ilSystemStyleIcon("nonsvg.png", $path4, "png");
141 
142  $expected_icons = [$icon2,$icon3,$icon1,$icon4];
143 
144  $folder = new ilSystemStyleIconFolder($this->container->getImagesSkinPath($this->style->getId()));
145  $this->assertEquals($expected_icons, $folder->getIcons());
146  }
"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: