ILIAS  release_8 Revision v8.24
ilSystemStyleIconTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once('libs/composer/vendor/autoload.php');
22
24{
25 protected string $icon_name = 'test_image_1.svg';
26 protected string $icon_type = 'svg';
27
28 public function testConstruct(): void
29 {
30 $path = $this->container->getImagesSkinPath($this->style->getId()) . '/' . $this->icon_name;
31 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
32
33 $this->assertEquals($icon->getName(), $this->icon_name);
34 $this->assertEquals($icon->getPath(), $path);
35 $this->assertEquals($icon->getType(), $this->icon_type);
36 }
37
38 public function testGetDirRelToCustomizing(): void
39 {
40 $path = $this->container->getImagesSkinPath($this->style->getId()) . '/' . $this->icon_name;
41 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
42
43 $this->assertEquals('', $icon->getDirRelToCustomizing());
44
45 $name = 'test.svg';
46 $rel_path = 'global/skin/unibe50/images';
47 $path = './Customizing' . $rel_path . '/' . $name;
48 $icon = new ilSystemStyleIcon($name, $path, 'svg');
49
50 $this->assertEquals($rel_path, $icon->getDirRelToCustomizing());
51 }
52
53 public function testGetColorSet(): void
54 {
55 $path = $this->container->getImagesSkinPath($this->style->getId()) . '/' . $this->icon_name;
56 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
57
58 $expected_color_set = new ilSystemStyleIconColorSet();
59 $color1 = new ilSystemStyleIconColor('id_505050', '505050', '505050', '505050');
60 $color2 = new ilSystemStyleIconColor('id_6B6B6B', '6B6B6B', '6B6B6B', '6B6B6B');
61 $color3 = new ilSystemStyleIconColor('id_838383', '838383', '838383', '838383');
62 $color4 = new ilSystemStyleIconColor('id_8C8C8C', '8C8C8C', '8C8C8C', '8C8C8C');
63 $expected_color_set->addColor($color1);
64 $expected_color_set->addColor($color2);
65 $expected_color_set->addColor($color3);
66 $expected_color_set->addColor($color4);
67
68 $this->assertEquals($expected_color_set, $icon->getColorSet());
69 }
70
71 public function testChangeColor(): void
72 {
73 $path = $this->container->getImagesSkinPath($this->style->getId()) . '/' . $this->icon_name;
74 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
75
76 $icon->changeColors(['505050' => '555555']);
77
78 $expected_color_set = new ilSystemStyleIconColorSet();
79 $color1 = new ilSystemStyleIconColor('id_555555', '555555', '555555', '555555');
80 $color2 = new ilSystemStyleIconColor('id_6B6B6B', '6B6B6B', '6B6B6B', '6B6B6B');
81 $color3 = new ilSystemStyleIconColor('id_838383', '838383', '838383', '838383');
82 $color4 = new ilSystemStyleIconColor('id_8C8C8C', '8C8C8C', '8C8C8C', '8C8C8C');
83 $expected_color_set->addColor($color1);
84 $expected_color_set->addColor($color2);
85 $expected_color_set->addColor($color3);
86 $expected_color_set->addColor($color4);
87
88 $this->assertEquals($expected_color_set, $icon->getColorSet());
89 }
90
91 public function testChangeColorInIconFile(): void
92 {
93 $path = $this->container->getImagesSkinPath($this->style->getId()) . '/' . $this->icon_name;
94 $icon = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
95
96 $icon->changeColors(['505050' => '555555']);
97
98 $expected_color_set = new ilSystemStyleIconColorSet();
99 $color1 = new ilSystemStyleIconColor('id_555555', '555555', '555555', '555555');
100 $color2 = new ilSystemStyleIconColor('id_6B6B6B', '6B6B6B', '6B6B6B', '6B6B6B');
101 $color3 = new ilSystemStyleIconColor('id_838383', '838383', '838383', '838383');
102 $color4 = new ilSystemStyleIconColor('id_8C8C8C', '8C8C8C', '8C8C8C', '8C8C8C');
103 $expected_color_set->addColor($color1);
104 $expected_color_set->addColor($color2);
105 $expected_color_set->addColor($color3);
106 $expected_color_set->addColor($color4);
107
108 $icon_new = new ilSystemStyleIcon($this->icon_name, $path, $this->icon_type);
109
110 $this->assertEquals($expected_color_set, $icon_new->getColorSet());
111 }
112}
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon.
$path
Definition: ltiservices.php:32
if($format !==null) $name
Definition: metadata.php:247