ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
SystemInfoTest.php
Go to the documentation of this file.
1 <?php
2 
8 
9 require_once("libs/composer/vendor/autoload.php");
10 require_once(__DIR__ . "/../../Base.php");
11 
17 {
18 
22  private $sig_gen;
23 
24  public function setUp() : void
25  {
26  parent::setUp();
27  $this->sig_gen = new SignalGenerator();
28  }
29 
30  public function testRenderingDefault()
31  {
32  $headline = 'That\'s one small step for [a] man';
33  $information = 'Lorem IPsum dolor sit amet';
34  $r = $this->getDefaultRenderer();
35  $system_info = new SystemInfo($this->sig_gen, $headline, $information);
36 
37  // Neutral
38  $expected = <<<EOT
39 <div id="id" class="container-fluid il-system-info il-system-info-neutral" data-close-uri="" aria-live="polite" aria-labelledby="il-system-info-headline" aria-describedby="il-system-info-headline">
40  <div class="il-system-info-content-wrapper">
41  <div class="il-system-info-content">
42  <span class="il-system-info-headline">$headline</span>
43  <span class="il-system-info-body">$information</span>
44  </div>
45  </div>
46  <div class="il-system-info-actions">
47  <span class="il-system-info-more">
48  <a class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
49  </span>
50  <span class="il-system-info-close"></span>
51  </div>
52 </div>
53 EOT;
54 
55  $actual = $r->render($system_info);
56  $this->assertEquals(
57  $this->brutallyTrimHTML($expected),
58  $this->brutallyTrimHTML($actual)
59  );
60  }
61 
62  public function testRenderingNeutral()
63  {
64  $headline = 'That\'s one small step for [a] man';
65  $information = 'Lorem IPsum dolor sit amet';
66  $r = $this->getDefaultRenderer();
67  $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
68  ->withDenotation(SystemInfo::DENOTATION_NEUTRAL);
69 
70  // Neutral
71  $expected = <<<EOT
72 <div id="id" class="container-fluid il-system-info il-system-info-neutral" data-close-uri="" aria-live="polite" aria-labelledby="il-system-info-headline" aria-describedby="il-system-info-headline">
73  <div class="il-system-info-content-wrapper">
74  <div class="il-system-info-content">
75  <span class="il-system-info-headline">$headline</span>
76  <span class="il-system-info-body">$information</span>
77  </div>
78  </div>
79  <div class="il-system-info-actions">
80  <span class="il-system-info-more">
81  <a class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
82  </span>
83  <span class="il-system-info-close"></span>
84  </div>
85 </div>
86 EOT;
87 
88  $actual = $r->render($system_info);
89  $this->assertEquals(
90  $this->brutallyTrimHTML($expected),
91  $this->brutallyTrimHTML($actual)
92  );
93  }
94 
95  public function testRenderingImportant()
96  {
97  $headline = 'That\'s one small step for [a] man';
98  $information = 'Lorem IPsum dolor sit amet';
99  $r = $this->getDefaultRenderer();
100  $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
101  ->withDenotation(SystemInfo::DENOTATION_IMPORTANT);
102 
103  $actual = $r->render($system_info);
104  $expected = <<<EOT
105 <div id="id" class="container-fluid il-system-info il-system-info-important" data-close-uri="" aria-live="polite" aria-labelledby="il-system-info-headline" aria-describedby="il-system-info-headline">
106  <div class="il-system-info-content-wrapper">
107  <div class="il-system-info-content">
108  <span class="il-system-info-headline">$headline</span>
109  <span class="il-system-info-body">$information</span>
110  </div>
111  </div>
112  <div class="il-system-info-actions">
113  <span class="il-system-info-more">
114  <a class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
115  </span>
116  <span class="il-system-info-close"></span>
117  </div>
118 </div>
119 EOT;
120 
121  $this->assertEquals(
122  $this->brutallyTrimHTML($expected),
123  $this->brutallyTrimHTML($actual)
124  );
125  }
126 
127  public function testRenderingBreaking()
128  {
129  $headline = 'That\'s one small step for [a] man';
130  $information = 'Lorem IPsum dolor sit amet';
131  $r = $this->getDefaultRenderer();
132  $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
133  ->withDenotation(SystemInfo::DENOTATION_BREAKING);
134 
135  // Breaking
136  $expected = <<<EOT
137 <div id="id" class="container-fluid il-system-info il-system-info-breaking" data-close-uri="" role="alert" aria-labelledby="il-system-info-headline" aria-describedby="il-system-info-headline">
138  <div class="il-system-info-content-wrapper">
139  <div class="il-system-info-content">
140  <span class="il-system-info-headline">$headline</span>
141  <span class="il-system-info-body">$information</span>
142  </div>
143  </div>
144  <div class="il-system-info-actions">
145  <span class="il-system-info-more">
146  <a class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
147  </span>
148  <span class="il-system-info-close"></span>
149  </div>
150 </div>
151 EOT;
152 
153  $actual = $r->render($system_info);
154  $this->assertEquals(
155  $this->brutallyTrimHTML($expected),
156  $this->brutallyTrimHTML($actual)
157  );
158  }
159 
160 
161  public function testRenderingCloseAction()
162  {
163  $headline = 'That\'s one small step for [a] man';
164  $information = 'Lorem IPsum dolor sit amet';
165  $uri_string = 'http://one_giant_leap?for=mankind';
166  $action = new URI($uri_string);
167  $r = $this->getDefaultRenderer();
168  $system_info = (new SystemInfo($this->sig_gen, $headline, $information))
169  ->withDismissAction($action);
170 
171  $expected = <<<EOT
172 <div id="id" class="container-fluid il-system-info il-system-info-neutral" data-close-uri="$uri_string" aria-live="polite" aria-labelledby="il-system-info-headline" aria-describedby="il-system-info-headline">
173  <div class="il-system-info-content-wrapper">
174  <div class="il-system-info-content">
175  <span class="il-system-info-headline">$headline</span>
176  <span class="il-system-info-body">$information</span>
177  </div>
178  </div>
179  <div class="il-system-info-actions">
180  <span class="il-system-info-more">
181  <a class="glyph" href="#" aria-label="show_more"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></a>
182  </span>
183  <span class="il-system-info-close"><a class="glyph" href="#" aria-label="close" id="id"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></span>
184  </div>
185 </div>
186 EOT;
187 
188  $actual = $r->render($system_info);
189  $this->assertEquals(
190  $this->brutallyTrimHTML($expected),
191  $this->brutallyTrimHTML($actual)
192  );
193  }
194 
195  public function getDefaultRenderer(JavaScriptBinding $js_binding = null, $with_stub_renderings = [])
196  {
197  return parent::getDefaultRenderer(new class implements \ILIAS\UI\Implementation\Render\JavaScriptBinding {
198  public function createId()
199  {
200  return "id";
201  }
202 
203  public $on_load_code = array();
204 
205  public function addOnLoadCode($code)
206  {
207  $this->on_load_code[] = $code;
208  }
209 
210  public function getOnLoadCodeAsync()
211  {
212  }
213  });
214  }
215 
216  public function getUIFactory()
217  {
218  $factory = new class() extends NoUIFactory {
219 
223  public function __construct()
224  {
225  $this->sig_gen = new SignalGenerator();
226  }
227 
228  public function symbol() : ILIAS\UI\Component\Symbol\Factory
229  {
230  return new Factory(
231  new \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory(),
232  new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory(),
233  new \ILIAS\UI\Implementation\Component\Symbol\Avatar\Factory()
234  );
235  }
236 
237  public function mainControls() : \ILIAS\UI\Component\MainControls\Factory
238  {
239  return new \ILIAS\UI\Implementation\Component\MainControls\Factory(
240  $this->sig_gen,
241  new \ILIAS\UI\Implementation\Component\MainControls\Slate\Factory(
242  $this->sig_gen,
243  new \ILIAS\UI\Implementation\Component\Counter\Factory(),
244  $this->symbol()
245  )
246  );
247  }
248  };
249  $factory->sig_gen = $this->sig_gen;
250 
251  return $factory;
252  }
253 }
close()
Definition: close.php:2
Class Factory.
Class ChatMainBarProvider .
Provides common functionality for UI tests.
Definition: Base.php:262
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:17
Provides methods to interface with javascript.
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
__construct(Container $dic, ilPlugin $plugin)
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
$factory
Definition: metadata.php:58
This is how a factory for buttons looks like.
Definition: Factory.php:12
Class SystemInfoTest.