ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
StandardPageTest Class Reference

Tests for the Standard Page. More...

+ Inheritance diagram for StandardPageTest:
+ Collaboration diagram for StandardPageTest:

Public Member Functions

 setUp ()
 
 testConstruction ()
 
 testGetContent ()
 
 testGetMetabar ()
 
 testGetMainbar ()
 
 testGetBreadcrumbs ()
 
 testGetLogo ()
 
 testHasLogo ()
 
 testGetResponsiveLogo ()
 
 testHasResponsiveLogo ()
 
 testWithFaviconPath ()
 
 testGetOverlay ()
 
 testWithWrongContents ()
 
 testGetTitle ()
 
 testWithTitle ()
 
 testWithShortTitle ()
 
 testWithViewTitle ()
 
 testWithTextDirection ()
 
 testWithMetaDatum ()
 
 testRenderingWithTitle ()
 
 testRenderingWithRtlLanguage ()
 
 testRenderingWithMetaData ()
 
 getUIFactory ()
 
 testRenderingWithCrumbs ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Attributes

Page Standard $stdpage
 
Page Factory $factory
 
MainBar $mainbar
 
MetaBar $metabar
 
Breadcrumbs $crumbs
 
Image $logo
 
Image $responsive_logo
 
Container $overlay
 
string $title
 
array $contents
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Tests for the Standard Page.

Definition at line 41 of file StandardPageTest.php.

Member Function Documentation

◆ getUIFactory()

StandardPageTest::getUIFactory ( )

Definition at line 368 of file StandardPageTest.php.

368  : NoUIFactory
369  {
370  return new class () extends NoUIFactory {
371  public function button(): \ILIAS\UI\Component\Button\Factory
372  {
373  return new Button\Factory();
374  }
375  public function dropdown(): Factory
376  {
377  return new Dropdown\Factory();
378  }
379  };
380  }
Class Factory.
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
This is how a factory for buttons looks like.
Definition: Factory.php:29

◆ setUp()

StandardPageTest::setUp ( )

Definition at line 58 of file StandardPageTest.php.

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

58  : void
59  {
60  $sig_gen = new SignalGenerator();
61  $this->metabar = $this->createMock(MetaBar::class);
62  $this->metabar->method("getCanonicalName")->willReturn("MetaBar Stub");
63  $this->mainbar = $this->createMock(MainBar::class);
64  $this->mainbar->method("getCanonicalName")->willReturn("MainBar Stub");
65  $this->crumbs = $this->createMock(Breadcrumbs::class);
66  $this->crumbs->method("getCanonicalName")->willReturn("Breadcrumbs Stub");
67  $this->logo = $this->createMock(Image::class);
68  $this->logo->method("getCanonicalName")->willReturn("Logo Stub");
69  $this->responsive_logo = $this->createMock(Image::class);
70  $this->responsive_logo->method("getCanonicalName")->willReturn("Responsive Logo Stub");
71  $this->overlay = $this->createMock(Container::class);
72  $this->overlay->method("getCanonicalName")->willReturn("Overlay Stub");
73  $this->contents = array(new Legacy('some content', $sig_gen));
74  $this->title = 'pagetitle';
75 
76  $this->factory = new Page\Factory();
77  $this->stdpage = $this->factory->standard(
78  $this->contents,
79  $this->metabar,
80  $this->mainbar,
81  $this->crumbs,
82  $this->logo,
83  $this->responsive_logo,
84  'favicon.ico',
85  $this->overlay,
86  null,
87  $this->title
88  );
89  }
This describes the Legacy-Slate.
Definition: Legacy.php:26
+ Here is the call graph for this function:

◆ testConstruction()

StandardPageTest::testConstruction ( )

Definition at line 91 of file StandardPageTest.php.

91  : void
92  {
93  $this->assertInstanceOf(
94  "ILIAS\\UI\\Component\\Layout\\Page\\Standard",
95  $this->stdpage
96  );
97  }

◆ testGetBreadcrumbs()

StandardPageTest::testGetBreadcrumbs ( )

Definition at line 123 of file StandardPageTest.php.

123  : void
124  {
125  $this->assertEquals(
126  $this->crumbs,
127  $this->stdpage->getBreadcrumbs()
128  );
129  }

◆ testGetContent()

StandardPageTest::testGetContent ( )

Definition at line 99 of file StandardPageTest.php.

99  : void
100  {
101  $this->assertEquals(
102  $this->contents,
103  $this->stdpage->getContent()
104  );
105  }

◆ testGetLogo()

StandardPageTest::testGetLogo ( )

Definition at line 131 of file StandardPageTest.php.

131  : void
132  {
133  $this->assertEquals(
134  $this->logo,
135  $this->stdpage->getLogo()
136  );
137  }

◆ testGetMainbar()

StandardPageTest::testGetMainbar ( )

Definition at line 115 of file StandardPageTest.php.

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

115  : void
116  {
117  $this->assertEquals(
118  $this->mainbar,
119  $this->stdpage->getMainbar()
120  );
121  }
+ Here is the call graph for this function:

◆ testGetMetabar()

StandardPageTest::testGetMetabar ( )

Definition at line 107 of file StandardPageTest.php.

107  : void
108  {
109  $this->assertEquals(
110  $this->metabar,
111  $this->stdpage->getMetabar()
112  );
113  }

◆ testGetOverlay()

StandardPageTest::testGetOverlay ( )

Definition at line 166 of file StandardPageTest.php.

166  : void
167  {
168  $this->assertEquals(
169  $this->overlay,
170  $this->stdpage->getOverlay()
171  );
172  }

◆ testGetResponsiveLogo()

StandardPageTest::testGetResponsiveLogo ( )

Definition at line 144 of file StandardPageTest.php.

144  : void
145  {
146  $this->assertEquals(
147  $this->responsive_logo,
148  $this->stdpage->getResponsiveLogo()
149  );
150  }

◆ testGetTitle()

StandardPageTest::testGetTitle ( )

Definition at line 186 of file StandardPageTest.php.

186  : void
187  {
188  $this->assertEquals(
189  $this->title,
190  $this->stdpage->getTitle()
191  );
192  }

◆ testHasLogo()

StandardPageTest::testHasLogo ( )

Definition at line 139 of file StandardPageTest.php.

139  : void
140  {
141  $this->assertTrue($this->stdpage->hasLogo());
142  }

◆ testHasResponsiveLogo()

StandardPageTest::testHasResponsiveLogo ( )

Definition at line 152 of file StandardPageTest.php.

152  : void
153  {
154  $this->assertTrue($this->stdpage->hasResponsiveLogo());
155  }

◆ testRenderingWithCrumbs()

StandardPageTest::testRenderingWithCrumbs ( )

Definition at line 382 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

382  : void
383  {
384  $crumbs = new Crumbs([
385  new CrumbEntry("label1", '#'),
386  new CrumbEntry("label2", '#'),
387  new CrumbEntry("label3", '#')
388  ]);
389  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->logo, $this->overlay]);
390 
391  $stdpage = $this->factory->standard(
392  $this->contents,
393  $this->metabar,
394  $this->mainbar,
395  $crumbs,
396  $this->logo,
397  $this->responsive_logo,
398  'favicon.ico',
399  $this->overlay,
400  null,
401  $this->title
402  );
403 
404  $html = $this->brutallyTrimHTML($r->render($stdpage));
405 
406  $exptected = $this->brutallyTrimHTML('<!DOCTYPE html>
407 <html lang="en" dir="ltr">
408 
409 <head>
410  <meta charset="utf-8" />
411  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
412  <meta name="viewport" content="width=device-width, initial-scale=1" />
413  <title>:</title>
414  <link rel="icon" href="favicon.ico" type="image/x-icon">
415  <style></style>
416 </head>
417 
418 <body>
419  <div class="il-page-overlay">Overlay Stub</div>
420  <div class="il-layout-page">
421  <header>
422  <div class="header-inner">
423  <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs">Responsive Logo Stub</span>
424  <div class="il-pagetitle">pagetitle</div>
425  </div>
426  <nav class="il-header-locator">
427  <div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="id_3" aria-haspopup="true" aria-expanded="false" aria-controls="id_3_menu">label3<span class="caret"></span></button>
428  <ul id="id_3_menu" class="dropdown-menu">
429  <li><button class="btn btn-link" data-action="#" id="id_1">label2</button></li>
430  <li><button class="btn btn-link" data-action="#" id="id_2">label1</button></li>
431  </ul>
432  </div>
433  </nav>MetaBar Stub
434  </div>
435  </header>
436  <div class="il-system-infos"></div>
437  <div class="nav il-maincontrols">MainBar Stub</div>
438  <main class="il-layout-page-content">
439  <div class="breadcrumbs">
440  <nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper">
441  <div class="breadcrumb"><span class="crumb"><a href="#">label1</a></span><span class="crumb"><a href="#">label2</a></span><span class="crumb"><a href="#">label3</a></span></div>
442  </nav>
443  </div>some content
444  </main>
445  </div>
446  <script>il.Util.addOnLoad(function() {});</script>
447 </body>
448 
449 </html>');
450  $this->assertEquals($exptected, $html);
451  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Page Standard $stdpage
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
+ Here is the call graph for this function:

◆ testRenderingWithMetaData()

StandardPageTest::testRenderingWithMetaData ( )

Definition at line 324 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

324  : void
325  {
326  $this->stdpage = $this->stdpage->withAdditionalMetaDatum('meta_datum_key_1', 'meta_datum_value_1');
327  $this->stdpage = $this->stdpage->withAdditionalMetaDatum('meta_datum_key_2', 'meta_datum_value_2');
328 
329  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->crumbs, $this->logo, $this->overlay]);
330  $html = $this->brutallyTrimHTML($r->render($this->stdpage));
331  $expected = $this->brutallyTrimHTML('
332 <!DOCTYPE html>
333 <html lang="en" dir="ltr">
334 
335 <head>
336  <meta charset="utf-8" />
337  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
338  <meta name="viewport" content="width=device-width, initial-scale=1" />
339  <title>:</title>
340  <link rel="icon" href="favicon.ico" type="image/x-icon">
341  <style></style>
342  <meta name="meta_datum_key_1" content="meta_datum_value_1" />
343  <meta name="meta_datum_key_2" content="meta_datum_value_2" />
344 </head>
345 
346 <body>
347  <div class="il-page-overlay">Overlay Stub</div>
348  <div class="il-layout-page">
349  <header>
350  <div class="header-inner">
351  <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs">Responsive Logo Stub</span>
352  <div class="il-pagetitle">pagetitle</div>
353  </div>MetaBar Stub
354  </div>
355  </header>
356  <div class="il-system-infos"></div>
357  <div class="nav il-maincontrols">MainBar Stub</div>
358  <main class="il-layout-page-content">some content</main>
359  </div>
360  <script>il.Util.addOnLoad(function() {});</script>
361 </body>
362 
363 </html>');
364  $this->assertEquals($expected, $html);
365  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
+ Here is the call graph for this function:

◆ testRenderingWithRtlLanguage()

StandardPageTest::testRenderingWithRtlLanguage ( )

Definition at line 284 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

284  : void
285  {
286  $this->stdpage = $this->stdpage->withTextDirection($this->stdpage::RTL);
287 
288  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->crumbs, $this->logo, $this->overlay]);
289  $html = $this->brutallyTrimHTML($r->render($this->stdpage));
290 
291  $exptected = $this->brutallyTrimHTML('<!DOCTYPE html>
292 <html lang="en" dir="rtl">
293 
294 <head>
295  <meta charset="utf-8" />
296  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
297  <meta name="viewport" content="width=device-width, initial-scale=1" />
298  <title>:</title>
299  <link rel="icon" href="favicon.ico" type="image/x-icon">
300  <style></style>
301 </head>
302 
303 <body>
304  <div class="il-page-overlay">Overlay Stub</div>
305  <div class="il-layout-page">
306  <header>
307  <div class="header-inner">
308  <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs">Responsive Logo Stub</span>
309  <div class="il-pagetitle">pagetitle</div>
310  </div>MetaBar Stub
311  </div>
312  </header>
313  <div class="il-system-infos"></div>
314  <div class="nav il-maincontrols">MainBar Stub</div>
315  <main class="il-layout-page-content">some content</main>
316  </div>
317  <script>il.Util.addOnLoad(function() {});</script>
318 </body>
319 
320 </html>');
321  $this->assertEquals($exptected, $html);
322  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
+ Here is the call graph for this function:

◆ testRenderingWithTitle()

StandardPageTest::testRenderingWithTitle ( )

Definition at line 241 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

241  : void
242  {
243  $this->stdpage = $this->stdpage
244  ->withTitle("Title")
245  ->withViewTitle("View Title")
246  ->withShortTitle("Short Title");
247 
248  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->crumbs, $this->logo, $this->overlay]);
249  $html = $this->brutallyTrimHTML($r->render($this->stdpage));
250 
251  $exptected = $this->brutallyTrimHTML('<!DOCTYPE html>
252 <html lang="en" dir="ltr">
253 
254 <head>
255  <meta charset="utf-8" />
256  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
257  <meta name="viewport" content="width=device-width, initial-scale=1" />
258  <title>View Title: Short Title</title>
259  <link rel="icon" href="favicon.ico" type="image/x-icon">
260  <style></style>
261 </head>
262 
263 <body>
264  <div class="il-page-overlay">Overlay Stub</div>
265  <div class="il-layout-page">
266  <header>
267  <div class="header-inner">
268  <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs">Responsive Logo Stub</span>
269  <div class="il-pagetitle">Title</div>
270  </div>MetaBar Stub
271  </div>
272  </header>
273  <div class="il-system-infos"></div>
274  <div class="nav il-maincontrols">MainBar Stub</div>
275  <main class="il-layout-page-content">some content</main>
276  </div>
277  <script>il.Util.addOnLoad(function() {});</script>
278 </body>
279 
280 </html>');
281  $this->assertEquals($exptected, $html);
282  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
+ Here is the call graph for this function:

◆ testWithFaviconPath()

StandardPageTest::testWithFaviconPath ( )

Definition at line 157 of file StandardPageTest.php.

157  : void
158  {
159  $this->assertEquals("favicon.ico", $this->stdpage->getFaviconPath());
160  $this->assertEquals(
161  "test",
162  $this->stdpage->withFaviconPath("test")->getFaviconPath()
163  );
164  }

◆ testWithMetaDatum()

StandardPageTest::testWithMetaDatum ( )

Definition at line 230 of file StandardPageTest.php.

230  : void
231  {
232  $meta_datum_key = 'meta_datum_key';
233  $meta_datum_value = 'meta_datum_value';
234  $meta_data = [$meta_datum_key => $meta_datum_value];
235  $this->assertEquals(
236  $meta_data,
237  $this->stdpage->withAdditionalMetaDatum($meta_datum_key, $meta_datum_value)->getMetaData()
238  );
239  }

◆ testWithShortTitle()

StandardPageTest::testWithShortTitle ( )

Definition at line 202 of file StandardPageTest.php.

202  : void
203  {
204  $title = 'some short title';
205  $this->assertEquals(
206  $title,
207  $this->stdpage->withShortTitle($title)->getShortTitle()
208  );
209  }

◆ testWithTextDirection()

StandardPageTest::testWithTextDirection ( )

Definition at line 219 of file StandardPageTest.php.

219  : void
220  {
221  $this->assertEquals("ltr", $this->stdpage->getTextDirection());
222  $this->assertEquals(
223  "rtl",
224  $this->stdpage
225  ->withTextDirection($this->stdpage::RTL)
226  ->getTextDirection()
227  );
228  }

◆ testWithTitle()

StandardPageTest::testWithTitle ( )

Definition at line 194 of file StandardPageTest.php.

194  : void
195  {
196  $title = 'some title';
197  $this->assertEquals(
198  $title,
199  $this->stdpage->withTitle($title)->getTitle()
200  );
201  }

◆ testWithViewTitle()

StandardPageTest::testWithViewTitle ( )

Definition at line 210 of file StandardPageTest.php.

210  : void
211  {
212  $title = 'some view title';
213  $this->assertEquals(
214  $title,
215  $this->stdpage->withViewTitle($title)->getViewTitle()
216  );
217  }

◆ testWithWrongContents()

StandardPageTest::testWithWrongContents ( )

Definition at line 174 of file StandardPageTest.php.

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

174  : void
175  {
176  $this->expectException(TypeError::class);
177  $this->stdpage = $this->factory->standard(
178  $this->metabar,
179  $this->mainbar,
180  'string is not allowed here',
181  $this->crumbs,
182  $this->logo
183  );
184  }
+ Here is the call graph for this function:

Field Documentation

◆ $contents

array StandardPageTest::$contents
protected

Definition at line 56 of file StandardPageTest.php.

◆ $crumbs

Breadcrumbs StandardPageTest::$crumbs
protected

Definition at line 47 of file StandardPageTest.php.

◆ $factory

Page Factory StandardPageTest::$factory
protected

Definition at line 44 of file StandardPageTest.php.

◆ $logo

Image StandardPageTest::$logo
protected

Definition at line 48 of file StandardPageTest.php.

◆ $mainbar

MainBar StandardPageTest::$mainbar
protected

Definition at line 45 of file StandardPageTest.php.

◆ $metabar

MetaBar StandardPageTest::$metabar
protected

Definition at line 46 of file StandardPageTest.php.

◆ $overlay

Container StandardPageTest::$overlay
protected

Definition at line 50 of file StandardPageTest.php.

◆ $responsive_logo

Image StandardPageTest::$responsive_logo
protected

Definition at line 49 of file StandardPageTest.php.

◆ $stdpage

Page Standard StandardPageTest::$stdpage
protected

Definition at line 43 of file StandardPageTest.php.

◆ $title

string StandardPageTest::$title
protected

Definition at line 51 of file StandardPageTest.php.


The documentation for this class was generated from the following file: