ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
SystemInfoTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 use ILIAS\Data\URI;
27 
28 require_once("libs/composer/vendor/autoload.php");
29 require_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>
68 EOT;
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>
101 EOT;
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>
134 EOT;
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>
166 EOT;
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>
201 EOT;
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 }
Class Factory.
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
SignalGenerator $sig_gen
Provides common functionality for UI tests.
Definition: Base.php:298
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34
Provides methods to interface with javascript.
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
__construct(Container $dic, ilPlugin $plugin)
$factory
Definition: metadata.php:75
This is how a factory for buttons looks like.
Definition: Factory.php:29
Class SystemInfoTest.