ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSystemStyleIconTest.php
Go to the documentation of this file.
1<?php
2
3include_once("Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
4include_once("Services/Style/System/classes/Utilities/class.ilSkinXML.php");
5include_once("Services/Style/System/classes/Utilities/class.ilSystemStyleSkinContainer.php");
6include_once("Services/Style/System/test/fixtures/mocks/ilSystemStyleConfigMock.php");
7include_once("Services/Style/System/test/fixtures/mocks/ilSystemStyleDICMock.php");
8
9include_once("Services/Style/System/classes/Icons/class.ilSystemStyleIcon.php");
10
11
18{
19
24
28 protected $container;
29
33 protected $style;
34
38 protected $icon_name = "test_image_1.svg";
39
43 protected $icon_type = "svg";
44
45
46 protected $save_dic = null;
47
48 protected function setUp()
49 {
50 global $DIC;
51
52 $this->save_dic = $DIC;
53
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 }
64
65 protected function tearDown()
66 {
67 global $DIC;
69 ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
70 }
71
72 public function testConstruct()
73 {
74 $path = $this->container->getImagesSkinPath($this->style->getId()) . "/" . $this->icon_name;
75 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
76
77 $this->assertEquals($icon->getName(), $this->icon_name);
78 $this->assertEquals($icon->getPath(), $path);
79 $this->assertEquals($icon->getType(), $this->icon_type);
80 }
81
83 {
84 $path = $this->container->getImagesSkinPath($this->style->getId()) . "/" . $this->icon_name;
85 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
86
87 $this->assertEquals($icon->getDirRelToCustomizing(), "");
88
89 $name = "test.svg";
90 $rel_path = "global/skin/unibe50/images";
91 $path = "./Customizing" . $rel_path . "/" . $name;
92 $icon = new ilSystemStyleIcon($name, $path, "svg");
93
94 $this->assertEquals($icon->getDirRelToCustomizing(), $rel_path);
95 }
96
97 public function testGetColorSet()
98 {
99 $path = $this->container->getImagesSkinPath($this->style->getId()) . "/" . $this->icon_name;
100 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
101
102 $expected_color_set = new ilSystemStyleIconColorSet();
103 $color1 = new ilSystemStyleIconColor("505050", "505050", "505050", "505050");
104 $color2 = new ilSystemStyleIconColor("6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
105 $color3 = new ilSystemStyleIconColor("838383", "838383", "838383", "838383");
106 $color4 = new ilSystemStyleIconColor("8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
107 $expected_color_set->addColor($color1);
108 $expected_color_set->addColor($color2);
109 $expected_color_set->addColor($color3);
110 $expected_color_set->addColor($color4);
111
112 $this->assertEquals($expected_color_set, $icon->getColorSet());
113 }
114
115 public function testChangeColor()
116 {
117 $path = $this->container->getImagesSkinPath($this->style->getId()) . "/" . $this->icon_name;
118 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
119
120 $icon->changeColors(['505050' => '555555']);
121
122 $expected_color_set = new ilSystemStyleIconColorSet();
123 $color1 = new ilSystemStyleIconColor("555555", "555555", "555555", "555555");
124 $color2 = new ilSystemStyleIconColor("6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
125 $color3 = new ilSystemStyleIconColor("838383", "838383", "838383", "838383");
126 $color4 = new ilSystemStyleIconColor("8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
127 $expected_color_set->addColor($color1);
128 $expected_color_set->addColor($color2);
129 $expected_color_set->addColor($color3);
130 $expected_color_set->addColor($color4);
131
132 $this->assertEquals($expected_color_set, $icon->getColorSet());
133 }
134
136 {
137 $path = $this->container->getImagesSkinPath($this->style->getId()) . "/" . $this->icon_name;
138 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
139
140 $icon->changeColors(['505050' => '555555']);
141
142 $expected_color_set = new ilSystemStyleIconColorSet();
143 $color1 = new ilSystemStyleIconColor("555555", "555555", "555555", "555555");
144 $color2 = new ilSystemStyleIconColor("6B6B6B", "6B6B6B", "6B6B6B", "6B6B6B");
145 $color3 = new ilSystemStyleIconColor("838383", "838383", "838383", "838383");
146 $color4 = new ilSystemStyleIconColor("8C8C8C", "8C8C8C", "8C8C8C", "8C8C8C");
147 $expected_color_set->addColor($color1);
148 $expected_color_set->addColor($color2);
149 $expected_color_set->addColor($color3);
150 $expected_color_set->addColor($color4);
151
152 $icon_new = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
153
154 $this->assertEquals($expected_color_set, $icon_new->getColorSet());
155 }
156}
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Class ilLanguageMock.
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon.
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.
static xCopy($src, $dest)
Recursive copy of a folder.
global $DIC
Definition: saml.php:7