ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 
 getDataFactory ()
 
 testRenderingWithCrumbs ()
 
 getMockedTag (string $html)
 

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
 

Detailed Description

Tests for the Standard Page.

Definition at line 43 of file StandardPageTest.php.

Member Function Documentation

◆ getDataFactory()

StandardPageTest::getDataFactory ( )

Definition at line 407 of file StandardPageTest.php.

407 : DataFactory
408 {
409 return new DataFactory();
410 }

◆ getMockedTag()

StandardPageTest::getMockedTag ( string  $html)

Definition at line 486 of file StandardPageTest.php.

486 : Html\Tag
487 {
488 return new class ($html) extends Html\Tag {
489 public function __construct(
490 protected string $html
491 ) {
492 }
493
494 public function toHtml(): string
495 {
496 return $this->html;
497 }
498 };
499 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

Referenced by testRenderingWithMetaData(), and testWithMetaDatum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

StandardPageTest::getUIFactory ( )

Definition at line 392 of file StandardPageTest.php.

393 {
394 return new class () extends NoUIFactory {
395 public function button(): Button\Factory
396 {
397 return new Button\Factory();
398 }
399
400 public function dropdown(): Dropdown\Factory
401 {
402 return new Dropdown\Factory();
403 }
404 };
405 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
This implements commonalities between different types of Dropdowns.
Definition: Dropdown.php:36
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References ILIAS\Repository\button().

+ Here is the call graph for this function:

◆ setUp()

StandardPageTest::setUp ( )

Definition at line 60 of file StandardPageTest.php.

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

References factory(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testConstruction()

StandardPageTest::testConstruction ( )

Definition at line 93 of file StandardPageTest.php.

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

◆ testGetBreadcrumbs()

StandardPageTest::testGetBreadcrumbs ( )

Definition at line 125 of file StandardPageTest.php.

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

◆ testGetContent()

StandardPageTest::testGetContent ( )

Definition at line 101 of file StandardPageTest.php.

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

◆ testGetLogo()

StandardPageTest::testGetLogo ( )

Definition at line 133 of file StandardPageTest.php.

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

◆ testGetMainbar()

StandardPageTest::testGetMainbar ( )

Definition at line 117 of file StandardPageTest.php.

117 : void
118 {
119 $this->assertEquals(
120 $this->mainbar,
121 $this->stdpage->getMainbar()
122 );
123 }

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

+ Here is the call graph for this function:

◆ testGetMetabar()

StandardPageTest::testGetMetabar ( )

Definition at line 109 of file StandardPageTest.php.

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

◆ testGetOverlay()

StandardPageTest::testGetOverlay ( )

Definition at line 168 of file StandardPageTest.php.

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

◆ testGetResponsiveLogo()

StandardPageTest::testGetResponsiveLogo ( )

Definition at line 146 of file StandardPageTest.php.

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

◆ testGetTitle()

StandardPageTest::testGetTitle ( )

Definition at line 188 of file StandardPageTest.php.

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

◆ testHasLogo()

StandardPageTest::testHasLogo ( )

Definition at line 141 of file StandardPageTest.php.

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

◆ testHasResponsiveLogo()

StandardPageTest::testHasResponsiveLogo ( )

Definition at line 154 of file StandardPageTest.php.

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

◆ testRenderingWithCrumbs()

StandardPageTest::testRenderingWithCrumbs ( )

Definition at line 412 of file StandardPageTest.php.

412 : void
413 {
414 $crumbs = new Crumbs([
415 new CrumbEntry("label1", '#'),
416 new CrumbEntry("label2", '#'),
417 new CrumbEntry("label3", '#')
418 ]);
419 $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->logo, $this->overlay]);
420
421 $stdpage = $this->factory->standard(
422 $this->contents,
423 $this->metabar,
424 $this->mainbar,
425 $crumbs,
426 $this->logo,
427 $this->responsive_logo,
428 'logo/favicon.ico',
429 $this->overlay,
430 null,
431 $this->title
432 );
433
434 $html = $this->brutallyTrimHTML($r->render($stdpage));
435
436 $exptected = $this->brutallyTrimHTML(
437 '<!DOCTYPE html>
438<html lang="en" dir="ltr">
439
440<head>
441 <meta charset="utf-8" />
442 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
443 <meta name="viewport" content="width=device-width, initial-scale=1" />
444 <title>:</title>
445 <link rel="icon" href="logo/favicon.ico" type="image/x-icon">
446 <script type="application/javascript">var il = il ||{}; window.il = il;</script>
447 <style></style>
448</head>
449
450<body class="c-layout__page">
451 <div class="il-page-overlay">Overlay Stub</div>
452 <div class="il-layout-page">
453 <header>
454 <div class="header-inner">
455 <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs-block">Responsive Logo Stub</span>
456 <div class="il-pagetitle">pagetitle</div>
457 </div>
458 <nav class="il-header-locator">
459 <div class="dropdown" id="id_3"><button class="btn btn-default dropdown-toggle" type="button" aria-haspopup="true" aria-expanded="false" aria-controls="id_3_menu">label3<span class="caret"></span></button>
460 <ul id="id_3_menu" class="dropdown-menu">
461 <li><button class="btn btn-link" data-action="#" id="id_1">label2</button></li>
462 <li><button class="btn btn-link" data-action="#" id="id_2">label1</button></li>
463 </ul>
464 </div>
465 </nav>MetaBar Stub
466 </div>
467 </header>
468 <div class="il-system-infos"></div>
469 <div class="nav il-maincontrols">MainBar Stub</div>
470 <main class="il-layout-page-content">
471 <div class="breadcrumbs">
472 <nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper">
473 <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>
474 </nav>
475 </div>some content
476 </main>
477 </div>
478 <script>il.Util.addOnLoad(function() {});</script>
479</body>
480
481</html>'
482 );
483 $this->assertEquals($exptected, $html);
484 }
Page Standard $stdpage

References $crumbs, $stdpage, factory(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testRenderingWithMetaData()

StandardPageTest::testRenderingWithMetaData ( )

Definition at line 339 of file StandardPageTest.php.

339 : void
340 {
341 $meta_datum_1_html = 'test_html_1';
342 $meta_datum_2_html = 'test_html_2';
343 $meta_datum_1 = $this->getMockedTag($meta_datum_1_html);
344 $meta_datum_2 = $this->getMockedTag($meta_datum_2_html);
345
346 $this->stdpage = $this->stdpage->withAdditionalMetaDatum($meta_datum_1);
347 $this->stdpage = $this->stdpage->withAdditionalMetaDatum($meta_datum_2);
348
349 $r = $this->getDefaultRenderer(
350 null,
351 [$this->metabar, $this->mainbar, $this->crumbs, $this->logo, $this->overlay]
352 );
353 $html = $this->brutallyTrimHTML($r->render($this->stdpage));
354 $expected = $this->brutallyTrimHTML(
355 '
356<!DOCTYPE html>
357<html lang="en" dir="ltr">
358
359<head>
360 <meta charset="utf-8" />
361 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
362 <meta name="viewport" content="width=device-width, initial-scale=1" />
363' . $meta_datum_1_html . $meta_datum_2_html . '
364 <title>:</title>
365 <link rel="icon" href="logo/favicon.ico" type="image/x-icon">
366 <script type="application/javascript">var il = il ||{}; window.il = il;</script>
367 <style></style>
368</head>
369
370<body class="c-layout__page">
371 <div class="il-page-overlay">Overlay Stub</div>
372 <div class="il-layout-page">
373 <header>
374 <div class="header-inner">
375 <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs-block">Responsive Logo Stub</span>
376 <div class="il-pagetitle">pagetitle</div>
377 </div>MetaBar Stub
378 </div>
379 </header>
380 <div class="il-system-infos"></div>
381 <div class="nav il-maincontrols">MainBar Stub</div>
382 <main class="il-layout-page-content">some content</main>
383 </div>
384 <script>il.Util.addOnLoad(function() {});</script>
385</body>
386
387</html>'
388 );
389 $this->assertEquals($expected, $html);
390 }
getMockedTag(string $html)

References getMockedTag(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testRenderingWithRtlLanguage()

StandardPageTest::testRenderingWithRtlLanguage ( )

Definition at line 293 of file StandardPageTest.php.

293 : void
294 {
295 $this->stdpage = $this->stdpage->withTextDirection($this->stdpage::RTL);
296
297 $r = $this->getDefaultRenderer(
298 null,
299 [$this->metabar, $this->mainbar, $this->crumbs, $this->logo, $this->overlay]
300 );
301 $html = $this->brutallyTrimHTML($r->render($this->stdpage));
302
303 $exptected = $this->brutallyTrimHTML(
304 '<!DOCTYPE html>
305<html lang="en" dir="rtl">
306
307<head>
308 <meta charset="utf-8" />
309 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
310 <meta name="viewport" content="width=device-width, initial-scale=1" />
311 <title>:</title>
312 <link rel="icon" href="logo/favicon.ico" type="image/x-icon">
313 <script type="application/javascript">var il = il ||{}; window.il = il;</script>
314 <style></style>
315</head>
316
317<body class="c-layout__page">
318 <div class="il-page-overlay">Overlay Stub</div>
319 <div class="il-layout-page">
320 <header>
321 <div class="header-inner">
322 <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs-block">Responsive Logo Stub</span>
323 <div class="il-pagetitle">pagetitle</div>
324 </div>MetaBar Stub
325 </div>
326 </header>
327 <div class="il-system-infos"></div>
328 <div class="nav il-maincontrols">MainBar Stub</div>
329 <main class="il-layout-page-content">some content</main>
330 </div>
331 <script>il.Util.addOnLoad(function() {});</script>
332</body>
333
334</html>'
335 );
336 $this->assertEquals($exptected, $html);
337 }

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

+ Here is the call graph for this function:

◆ testRenderingWithTitle()

StandardPageTest::testRenderingWithTitle ( )

Definition at line 244 of file StandardPageTest.php.

244 : void
245 {
246 $this->stdpage = $this->stdpage
247 ->withTitle("Title")
248 ->withViewTitle("View Title")
249 ->withShortTitle("Short Title");
250
251 $r = $this->getDefaultRenderer(
252 null,
253 [$this->metabar, $this->mainbar, $this->crumbs, $this->logo, $this->overlay]
254 );
255 $html = $this->brutallyTrimHTML($r->render($this->stdpage));
256
257 $exptected = $this->brutallyTrimHTML(
258 '<!DOCTYPE html>
259<html lang="en" dir="ltr">
260
261<head>
262 <meta charset="utf-8" />
263 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
264 <meta name="viewport" content="width=device-width, initial-scale=1" />
265 <title>View Title: Short Title</title>
266 <link rel="icon" href="logo/favicon.ico" type="image/x-icon">
267 <script type="application/javascript">var il = il ||{}; window.il = il;</script>
268 <style></style>
269</head>
270
271<body class="c-layout__page">
272 <div class="il-page-overlay">Overlay Stub</div>
273 <div class="il-layout-page">
274 <header>
275 <div class="header-inner">
276 <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs-block">Responsive Logo Stub</span>
277 <div class="il-pagetitle">Title</div>
278 </div>MetaBar Stub
279 </div>
280 </header>
281 <div class="il-system-infos"></div>
282 <div class="nav il-maincontrols">MainBar Stub</div>
283 <main class="il-layout-page-content">some content</main>
284 </div>
285 <script>il.Util.addOnLoad(function() {});</script>
286</body>
287
288</html>'
289 );
290 $this->assertEquals($exptected, $html);
291 }

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

+ Here is the call graph for this function:

◆ testWithFaviconPath()

StandardPageTest::testWithFaviconPath ( )

Definition at line 159 of file StandardPageTest.php.

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

◆ testWithMetaDatum()

StandardPageTest::testWithMetaDatum ( )

Definition at line 234 of file StandardPageTest.php.

234 : void
235 {
236 $meta_datum_html = 'test_html';
237 $meta_datum = $this->getMockedTag($meta_datum_html);
238 $this->assertEquals(
239 [$meta_datum],
240 $this->stdpage->withAdditionalMetaDatum($meta_datum)->getMetaData()
241 );
242 }

References getMockedTag().

+ Here is the call graph for this function:

◆ testWithShortTitle()

StandardPageTest::testWithShortTitle ( )

Definition at line 205 of file StandardPageTest.php.

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

References $title.

◆ testWithTextDirection()

StandardPageTest::testWithTextDirection ( )

Definition at line 223 of file StandardPageTest.php.

223 : void
224 {
225 $this->assertEquals("ltr", $this->stdpage->getTextDirection());
226 $this->assertEquals(
227 "rtl",
228 $this->stdpage
229 ->withTextDirection($this->stdpage::RTL)
230 ->getTextDirection()
231 );
232 }

◆ testWithTitle()

StandardPageTest::testWithTitle ( )

Definition at line 196 of file StandardPageTest.php.

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

References $title.

◆ testWithViewTitle()

StandardPageTest::testWithViewTitle ( )

Definition at line 214 of file StandardPageTest.php.

214 : void
215 {
216 $title = 'some view title';
217 $this->assertEquals(
218 $title,
219 $this->stdpage->withViewTitle($title)->getViewTitle()
220 );
221 }

References $title.

◆ testWithWrongContents()

StandardPageTest::testWithWrongContents ( )

Definition at line 176 of file StandardPageTest.php.

176 : void
177 {
178 $this->expectException(TypeError::class);
179 $this->stdpage = $this->factory->standard(
180 $this->metabar,
181 $this->mainbar,
182 'string is not allowed here',
183 $this->crumbs,
184 $this->logo
185 );
186 }

References factory(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

Field Documentation

◆ $contents

array StandardPageTest::$contents
protected

Definition at line 58 of file StandardPageTest.php.

◆ $crumbs

Breadcrumbs StandardPageTest::$crumbs
protected

Definition at line 49 of file StandardPageTest.php.

Referenced by testRenderingWithCrumbs().

◆ $factory

Page Factory StandardPageTest::$factory
protected

Definition at line 46 of file StandardPageTest.php.

◆ $logo

Image StandardPageTest::$logo
protected

Definition at line 50 of file StandardPageTest.php.

◆ $mainbar

MainBar StandardPageTest::$mainbar
protected

Definition at line 47 of file StandardPageTest.php.

◆ $metabar

MetaBar StandardPageTest::$metabar
protected

Definition at line 48 of file StandardPageTest.php.

◆ $overlay

Container StandardPageTest::$overlay
protected

Definition at line 52 of file StandardPageTest.php.

◆ $responsive_logo

Image StandardPageTest::$responsive_logo
protected

Definition at line 51 of file StandardPageTest.php.

◆ $stdpage

Page Standard StandardPageTest::$stdpage
protected

Definition at line 45 of file StandardPageTest.php.

Referenced by testRenderingWithCrumbs().

◆ $title

string StandardPageTest::$title
protected

Definition at line 53 of file StandardPageTest.php.

Referenced by testWithShortTitle(), testWithTitle(), and testWithViewTitle().


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