ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SystemInfoTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27
28require_once("vendor/composer/vendor/autoload.php");
29require_once(__DIR__ . "/../../Base.php");
30
36{
38
39 public function setUp(): void
40 {
41 parent::setUp();
42 $this->sig_gen = new SignalGenerator();
43 }
44
45 public function testRenderingDefault(): void
46 {
47 $headline = 'That\'s one small step for [a] man';
48 $information = 'Lorem IPsum dolor sit amet';
49 $r = $this->getDefaultRenderer();
50 $system_info = new SystemInfo($this->sig_gen, $headline, $information);
51
52 // Neutral
53 $expected = <<<EOT
54<div id="id" class="container-fluid il-system-info il-system-info-neutral" data-close-uri="" aria-live="polite" aria-labelledby="id_headline" aria-describedby="id_description">
55 <div class="il-system-info-content-wrapper">
56 <div class="il-system-info-content">
57 <div id="id_headline" class="il-system-info-headline">$headline</div>
58 <div id="id_description" class="il-system-info-body">$information</div>
59 </div>
60 </div>
61 <div class="il-system-info-actions">
62 <span class="il-system-info-more">
63 <a tabindex="0" class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
64 </span>
65 <span class="il-system-info-close"></span>
66 </div>
67</div>
68EOT;
69
70 $actual = $r->render($system_info);
71 $this->assertEquals(
72 $this->brutallyTrimHTML($expected),
73 $this->brutallyTrimHTML($actual)
74 );
75 }
76
77 public function testRenderingNeutral(): void
78 {
79 $headline = 'That\'s one small step for [a] man';
80 $information = 'Lorem IPsum dolor sit amet';
81 $r = $this->getDefaultRenderer();
82 $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
83 ->withDenotation(SystemInfoAlias::DENOTATION_NEUTRAL);
84
85 // Neutral
86 $expected = <<<EOT
87<div id="id" class="container-fluid il-system-info il-system-info-neutral" data-close-uri="" aria-live="polite" aria-labelledby="id_headline" aria-describedby="id_description">
88 <div class="il-system-info-content-wrapper">
89 <div class="il-system-info-content">
90 <div id="id_headline" class="il-system-info-headline">$headline</div>
91 <div id="id_description" class="il-system-info-body">$information</div>
92 </div>
93 </div>
94 <div class="il-system-info-actions">
95 <span class="il-system-info-more">
96 <a tabindex="0" class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
97 </span>
98 <span class="il-system-info-close"></span>
99 </div>
100</div>
101EOT;
102
103 $actual = $r->render($system_info);
104 $this->assertEquals(
105 $this->brutallyTrimHTML($expected),
106 $this->brutallyTrimHTML($actual)
107 );
108 }
109
110 public function testRenderingImportant(): void
111 {
112 $headline = 'That\'s one small step for [a] man';
113 $information = 'Lorem IPsum dolor sit amet';
114 $r = $this->getDefaultRenderer();
115 $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
116 ->withDenotation(SystemInfoAlias::DENOTATION_IMPORTANT);
117
118 $actual = $r->render($system_info);
119 $expected = <<<EOT
120<div id="id" class="container-fluid il-system-info il-system-info-important" data-close-uri="" aria-live="polite" aria-labelledby="id_headline" aria-describedby="id_description">
121 <div class="il-system-info-content-wrapper">
122 <div class="il-system-info-content">
123 <div id="id_headline" class="il-system-info-headline">$headline</div>
124 <div id="id_description" class="il-system-info-body">$information</div>
125 </div>
126 </div>
127 <div class="il-system-info-actions">
128 <span class="il-system-info-more">
129 <a tabindex="0" class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
130 </span>
131 <span class="il-system-info-close"></span>
132 </div>
133</div>
134EOT;
135
136 $this->assertEquals(
137 $this->brutallyTrimHTML($expected),
138 $this->brutallyTrimHTML($actual)
139 );
140 }
141
142 public function testRenderingBreaking(): void
143 {
144 $headline = 'That\'s one small step for [a] man';
145 $information = 'Lorem IPsum dolor sit amet';
146 $r = $this->getDefaultRenderer();
147 $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
148 ->withDenotation(SystemInfoAlias::DENOTATION_BREAKING);
149
150 // Breaking
151 $expected = <<<EOT
152<div id="id" class="container-fluid il-system-info il-system-info-breaking" data-close-uri="" role="alert" aria-labelledby="id_headline" aria-describedby="id_description">
153 <div class="il-system-info-content-wrapper">
154 <div class="il-system-info-content">
155 <div id="id_headline" class="il-system-info-headline">$headline</div>
156 <div id="id_description" class="il-system-info-body">$information</div>
157 </div>
158 </div>
159 <div class="il-system-info-actions">
160 <span class="il-system-info-more">
161 <a tabindex="0" class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
162 </span>
163 <span class="il-system-info-close"></span>
164 </div>
165</div>
166EOT;
167
168 $actual = $r->render($system_info);
169 $this->assertEquals(
170 $this->brutallyTrimHTML($expected),
171 $this->brutallyTrimHTML($actual)
172 );
173 }
174
175
176 public function testRenderingCloseAction(): void
177 {
178 $headline = 'That\'s one small step for [a] man';
179 $information = 'Lorem IPsum dolor sit amet';
180 $uri_string = 'http://one_giant_leap?for=mankind';
181 $action = new URI($uri_string);
182 $r = $this->getDefaultRenderer();
183 $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
184 ->withDismissAction($action);
185
186 $expected = <<<EOT
187<div id="id" class="container-fluid il-system-info il-system-info-neutral" data-close-uri="$uri_string" aria-live="polite" aria-labelledby="id_headline" aria-describedby="id_description">
188 <div class="il-system-info-content-wrapper">
189 <div class="il-system-info-content">
190 <div id="id_headline" class="il-system-info-headline">$headline</div>
191 <div id="id_description" class="il-system-info-body">$information</div>
192 </div>
193 </div>
194 <div class="il-system-info-actions">
195 <span class="il-system-info-more">
196 <a tabindex="0" class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
197 </span>
198 <span class="il-system-info-close"><a tabindex="0" class="glyph" href="#" aria-label="close" id="id"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></span>
199 </div>
200</div>
201EOT;
202
203 $actual = $r->render($system_info);
204 $this->assertEquals(
205 $this->brutallyTrimHTML($expected),
206 $this->brutallyTrimHTML($actual)
207 );
208 }
209
210 public function getDefaultRenderer(
211 ?JavaScriptBinding $js_binding = null,
212 array $with_stub_renderings = [],
213 array $with_additional_contexts = [],
215 return parent::getDefaultRenderer(new class () implements JavaScriptBinding {
216 public function createId(): string
217 {
218 return "id";
219 }
220
221 public array $on_load_code = array();
222
223 public function addOnLoadCode(string $code): void
224 {
225 $this->on_load_code[] = $code;
226 }
227
228 public function getOnLoadCodeAsync(): string
229 {
230 }
231 });
232 }
233
234 public function getUIFactory(): NoUIFactory
235 {
236 $factory = new class () extends NoUIFactory {
237 public SignalGenerator $sig_gen;
238
239 public function __construct()
240 {
241 $this->sig_gen = new SignalGenerator();
242 }
243
245 {
246 return new Factory(
247 new \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory(),
248 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory(),
249 new \ILIAS\UI\Implementation\Component\Symbol\Avatar\Factory()
250 );
251 }
252
253 public function mainControls(): \ILIAS\UI\Implementation\Component\MainControls\Factory
254 {
255 return new \ILIAS\UI\Implementation\Component\MainControls\Factory(
256 $this->sig_gen,
257 new \ILIAS\UI\Implementation\Component\MainControls\Slate\Factory(
258 $this->sig_gen,
259 new \ILIAS\UI\Implementation\Component\Counter\Factory(),
260 $this->symbol()
261 )
262 );
263 }
264 };
265 $factory->sig_gen = $this->sig_gen;
266
267 return $factory;
268 }
269}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Provides common functionality for UI tests.
Definition: Base.php:337
Class SystemInfoTest.
getDefaultRenderer(?JavaScriptBinding $js_binding=null, array $with_stub_renderings=[], array $with_additional_contexts=[],)
SignalGenerator $sig_gen
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Provides methods to interface with javascript.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.