ILIAS  release_8 Revision v8.24
ilSkinStyleContainerTest.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 ilSkin $skin;
29
30 protected function setUp(): void
31 {
32 parent::setUp();
33
34 if (!defined('PATH_TO_LESSC')) {
35 if (file_exists('ilias.ini.php')) {
36 $ini = parse_ini_file('ilias.ini.php', true);
37 define('PATH_TO_LESSC', $ini['tools']['lessc'] ?? '');
38 } else {
39 define('PATH_TO_LESSC', '');
40 }
41 }
42
43 $this->skin = new ilSkin('skin1', 'skin 1');
44
45 $this->style1 = new ilSkinStyle('style1', 'Style 1');
46 $this->style1->setCssFile('style1css');
47 $this->style1->setImageDirectory('style1image');
48 $this->style1->setSoundDirectory('style1sound');
49 $this->style1->setFontDirectory('style1font');
50
51 $this->style2 = new ilSkinStyle('style2', 'Style 2');
52 $this->style2->setCssFile('style2css');
53 $this->style2->setImageDirectory('style2image');
54 $this->style2->setSoundDirectory('style2sound');
55 $this->style2->setFontDirectory('style2font');
56
57 $this->factory = new ilSkinFactory($this->lng, $this->system_style_config);
58 }
59
60 public function testCreateDelete(): void
61 {
62 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
63
64 $container->getSkin()->setId('newSkin');
65 $container->create($this->message_stack);
66
67 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . 'newSkin'));
69 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . 'newSkin'));
70 }
71
72 public function testUpdateSkinNoIdChange(): void
73 {
74 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
76 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId()));
77 }
78
79 public function testUpdateSkinWithChangedID(): void
80 {
81 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
82 $old_skin = clone $container->getSkin();
83 $container->getSkin()->setId('newSkin2');
84 $container->updateSkin($old_skin);
85 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . 'newSkin2'));
86 $old_skin = clone $container->getSkin();
87 $container->getSkin()->setId($this->skin->getId());
88 $container->updateSkin($old_skin);
89 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . 'newSkin2'));
90 }
91
92 public function testAddStyle(): void
93 {
94 $new_style = new ilSkinStyle('style1new', 'new Style');
95 $new_style->setCssFile('style1new');
96 $new_style->setImageDirectory('style1newimage');
97 $new_style->setSoundDirectory('style1newsound');
98 $new_style->setFontDirectory('style1newfont');
99
100 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
101
102 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1image'));
103 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1sound'));
104 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1font'));
105 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.css'));
106 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.less'));
107 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css-variables.less'));
108
109 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newimage'));
110 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newsound'));
111 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newfont'));
112 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new.css'));
113 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new.less'));
114 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new-variables.less'));
115
116 $container->addStyle($new_style);
117
118 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1image'));
119 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1sound'));
120 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1font'));
121 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.css'));
122 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.less'));
123 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css-variables.less'));
124
125 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newimage'));
126 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newsound'));
127 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newfont'));
128 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new.css'));
129 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new.less'));
130 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new-variables.less'));
131 }
132
133 public function testDeleteStyle(): void
134 {
135 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
136
137 $container->deleteStyle($this->style1);
138
139 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1image'));
140 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1sound'));
141 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1font'));
142 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.css'));
143 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.less'));
144 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css-variables.less'));
145
146 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style2image'));
147 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style2sound'));
148 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style2font'));
149 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style2css.css'));
150 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style2css.less'));
151 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style2css-variables.less'));
152 }
153
154 public function testUpdateStyle(): void
155 {
156 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
158
159 $old_style = clone $skin->getStyle($this->style1->getId());
160 $new_style = $skin->getStyle($this->style1->getId());
161
162 $new_style->setId('style1new');
163 $new_style->setName('new Style');
164 $new_style->setCssFile('style1new');
165 $new_style->setImageDirectory('style1newimage');
166 $new_style->setSoundDirectory('style1newsound');
167 $new_style->setFontDirectory('style1newfont');
168
169 $container->updateStyle($new_style->getId(), $old_style);
170
171 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1image'));
172 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1sound'));
173 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1font'));
174 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.css'));
175 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css.less'));
176 $this->assertFalse(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1css-variables.less'));
177
178 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newimage'));
179 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newsound'));
180 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1newfont'));
181 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new.css'));
182 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new.less'));
183 $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $this->skin->getId() . '/style1new-variables.less'));
184 }
185
186 public function testDeleteSkin(): void
187 {
188 $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
190
191 $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId()));
193 $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId()));
194 }
195}
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
updateSkin(ilSkin $old_skin=null)
Updates the skin.
delete()
Deletes the container of a skin completely.
deleteStyle(ilSkinStyle $style)
Deletes a style completely.
create(ilSystemStyleMessageStack $message_stack)
Creates a new skin.
updateStyle(string $style_id, ilSkinStyle $old_style)
Updates one single style.
ilSkin holds an manages the basic data of a skin as provide by the template of the skin.
getStyle(string $id)
ilSkinStyleContainer $container
$ini
Definition: raiseError.php:4