ILIAS  release_8 Revision v8.24
SystemInfoTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27
28require_once("libs/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 <span id="id_headline" class="il-system-info-headline">$headline</span>
58 <span id="id_description" class="il-system-info-body">$information</span>
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 <span id="id_headline" class="il-system-info-headline">$headline</span>
91 <span id="id_description" class="il-system-info-body">$information</span>
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 <span id="id_headline" class="il-system-info-headline">$headline</span>
124 <span id="id_description" class="il-system-info-body">$information</span>
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 <span id="id_headline" class="il-system-info-headline">$headline</span>
156 <span id="id_description" class="il-system-info-body">$information</span>
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 <span id="id_headline" class="il-system-info-headline">$headline</span>
191 <span id="id_description" class="il-system-info-body">$information</span>
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 = []
214 return parent::getDefaultRenderer(new class () implements JavaScriptBinding {
215 public function createId(): string
216 {
217 return "id";
218 }
219
220 public array $on_load_code = array();
221
222 public function addOnLoadCode(string $code): void
223 {
224 $this->on_load_code[] = $code;
225 }
226
227 public function getOnLoadCodeAsync(): string
228 {
229 }
230 });
231 }
232
233 public function getUIFactory(): NoUIFactory
234 {
235 $factory = new class () extends NoUIFactory {
236 public SignalGenerator $sig_gen;
237
238 public function __construct()
239 {
240 $this->sig_gen = new SignalGenerator();
241 }
242
243 public function symbol(): ILIAS\UI\Component\Symbol\Factory
244 {
245 return new Factory(
246 new \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory(),
247 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory(),
248 new \ILIAS\UI\Implementation\Component\Symbol\Avatar\Factory()
249 );
250 }
251
252 public function mainControls(): \ILIAS\UI\Component\MainControls\Factory
253 {
254 return new \ILIAS\UI\Implementation\Component\MainControls\Factory(
255 $this->sig_gen,
256 new \ILIAS\UI\Implementation\Component\MainControls\Slate\Factory(
257 $this->sig_gen,
258 new \ILIAS\UI\Implementation\Component\Counter\Factory(),
259 $this->symbol()
260 )
261 );
262 }
263 };
264 $factory->sig_gen = $this->sig_gen;
265
266 return $factory;
267 }
268}
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
Builds a Color from either hex- or rgb values.
Definition: Factory.php:17
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:299
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
Class SystemInfoTest.
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
SignalGenerator $sig_gen
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
Provides methods to interface with javascript.
$factory
Definition: metadata.php:75
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.