ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 testWithWrongContents ()
 
 testGetTitle ()
 
 testWithTitle ()
 
 testWithShortTitle ()
 
 testWithViewTitle ()
 
 testWithTextDirection ()
 
 testWithMetaDatum ()
 
 testRenderingWithTitle ()
 
 testRenderingWithMetaData ()
 
 testRenderingWithRtlLanguage ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Attributes

 $stdpage
 
 $factory
 
 $mainbar
 
 $metabar
 
 $crumbs
 
 $logo
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Tests for the Standard Page.

Definition at line 19 of file StandardPageTest.php.

Member Function Documentation

◆ setUp()

StandardPageTest::setUp ( )

Definition at line 51 of file StandardPageTest.php.

References mainbar(), and metabar().

51  : void
52  {
53  $sig_gen = new \ILIAS\UI\Implementation\Component\SignalGenerator();
54  $this->metabar = $this->createMock(MetaBar::class);
55  $this->metabar->method("getCanonicalName")->willReturn("MetaBar Stub");
56  $this->mainbar = $this->createMock(MainBar::class);
57  $this->mainbar->method("getCanonicalName")->willReturn("MainBar Stub");
58  $this->crumbs = $this->createMock(Breadcrumbs::class);
59  $this->crumbs->method("getCanonicalName")->willReturn("Breadcrumbs Stub");
60  $this->logo = $this->createMock(Image::class);
61  $this->logo->method("getCanonicalName")->willReturn("Logo Stub");
62  $this->responsive_logo = $this->createMock(Image::class);
63  $this->responsive_logo->method("getCanonicalName")->willReturn("Responsive Logo Stub");
64  $this->contents = array(new Legacy('some content', $sig_gen));
65  $this->title = 'pagetitle';
66 
67  $this->factory = new Page\Factory();
68  $this->stdpage = $this->factory->standard(
69  $this->contents,
70  $this->metabar,
71  $this->mainbar,
72  $this->crumbs,
73  $this->logo,
74  null,
75  $this->title
76  )->withResponsiveLogo($this->responsive_logo);
77  }
This describes the Legacy-Slate.
Definition: Legacy.php:10
metabar()
Definition: metabar.php:2
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testConstruction()

StandardPageTest::testConstruction ( )

Definition at line 79 of file StandardPageTest.php.

79  : void
80  {
81  $this->assertInstanceOf(
82  "ILIAS\\UI\\Component\\Layout\\Page\\Standard",
83  $this->stdpage
84  );
85  }

◆ testGetBreadcrumbs()

StandardPageTest::testGetBreadcrumbs ( )

Definition at line 111 of file StandardPageTest.php.

111  : void
112  {
113  $this->assertEquals(
114  $this->crumbs,
115  $this->stdpage->getBreadcrumbs()
116  );
117  }

◆ testGetContent()

StandardPageTest::testGetContent ( )

Definition at line 87 of file StandardPageTest.php.

87  : void
88  {
89  $this->assertEquals(
90  $this->contents,
91  $this->stdpage->getContent()
92  );
93  }

◆ testGetLogo()

StandardPageTest::testGetLogo ( )

Definition at line 119 of file StandardPageTest.php.

119  : void
120  {
121  $this->assertEquals(
122  $this->logo,
123  $this->stdpage->getLogo()
124  );
125  }

◆ testGetMainbar()

StandardPageTest::testGetMainbar ( )

Definition at line 103 of file StandardPageTest.php.

References mainbar().

103  : void
104  {
105  $this->assertEquals(
106  $this->mainbar,
107  $this->stdpage->getMainbar()
108  );
109  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testGetMetabar()

StandardPageTest::testGetMetabar ( )

Definition at line 95 of file StandardPageTest.php.

References metabar().

95  : void
96  {
97  $this->assertEquals(
98  $this->metabar,
99  $this->stdpage->getMetabar()
100  );
101  }
metabar()
Definition: metabar.php:2
+ Here is the call graph for this function:

◆ testGetResponsiveLogo()

StandardPageTest::testGetResponsiveLogo ( )

Definition at line 132 of file StandardPageTest.php.

132  : void
133  {
134  $this->assertEquals(
135  $this->responsive_logo,
136  $this->stdpage->getResponsiveLogo()
137  );
138  }

◆ testGetTitle()

StandardPageTest::testGetTitle ( )

Definition at line 157 of file StandardPageTest.php.

157  : void
158  {
159  $this->assertEquals(
160  $this->title,
161  $this->stdpage->getTitle()
162  );
163  }

◆ testHasLogo()

StandardPageTest::testHasLogo ( )

Definition at line 127 of file StandardPageTest.php.

127  : void
128  {
129  $this->assertTrue($this->stdpage->hasLogo());
130  }

◆ testHasResponsiveLogo()

StandardPageTest::testHasResponsiveLogo ( )

Definition at line 140 of file StandardPageTest.php.

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

◆ testRenderingWithMetaData()

StandardPageTest::testRenderingWithMetaData ( )

Definition at line 257 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), mainbar(), and metabar().

258  {
259  $this->stdpage = $this->stdpage->withAdditionalMetaDatum('meta_datum_key_1', 'meta_datum_value_1');
260  $this->stdpage = $this->stdpage->withAdditionalMetaDatum('meta_datum_key_2', 'meta_datum_value_2');
261 
262  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->crumbs, $this->logo]);
263  $html = $this->brutallyTrimHTML($r->render($this->stdpage));
264  $expected = $this->brutallyTrimHTML('
265 <!DOCTYPE html>
266 <html lang="en" dir="ltr">
267  <head>
268  <meta charset="utf-8" />
269  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
270  <meta name="viewport" content="width=device-width, initial-scale=1" />
271  <title>:</title>
272  <style></style>
273  <meta name="meta_datum_key_1" content="meta_datum_value_1" />
274  <meta name="meta_datum_key_2" content="meta_datum_value_2" />
275  </head>
276  <body>
277  <div class="il-layout-page">
278  <header>
279  <div class="header-inner">
280  <div class="il-logo"><span class="hidden-xs">Logo Stub</span><span class="visible-xs">Responsive Logo Stub</span>
281  <div class="il-pagetitle">pagetitle</div>
282  </div>MetaBar Stub
283  </div>
284  </header>
285  <div class="breadcrumbs"></div>
286  <div class="il-system-infos"></div>
287  <div class="nav il-maincontrols">MainBar Stub</div>
288  <!-- html5 main-tag is not supported in IE / div is needed -->
289  <main class="il-layout-page-content">
290  <div>some content</div>
291  </main>
292  </div>
293  <script>il.Util.addOnLoad(function() {});</script>
294  </body>
295 </html>');
296  $this->assertEquals($expected, $html);
297  }
metabar()
Definition: metabar.php:2
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
mainbar()
Definition: mainbar.php:2
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testRenderingWithRtlLanguage()

StandardPageTest::testRenderingWithRtlLanguage ( )

Definition at line 299 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), mainbar(), and metabar().

299  : void
300  {
301  $this->stdpage = $this->stdpage->withTextDirection($this->stdpage::RTL);
302 
303  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->crumbs, $this->logo]);
304  $html = $this->brutallyTrimHTML($r->render($this->stdpage));
305 
306  $exptected = $this->brutallyTrimHTML('
307 <!DOCTYPE html>
308 <html lang="en" dir="rtl">
309  <head>
310  <meta charset="utf-8" />
311  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
312  <meta name="viewport" content="width=device-width, initial-scale=1" />
313  <title>: </title>
314  <style></style>
315  </head>
316  <body>
317  <div class="il-layout-page">
318  <header>
319  <div class="header-inner">
320  <div class="il-logo">
321  <span class="hidden-xs">Logo Stub</span>
322  <span class="visible-xs">Responsive Logo Stub</span>
323  <div class="il-pagetitle">pagetitle</div>
324  </div>MetaBar Stub
325  </div>
326  </header>
327  <div class="breadcrumbs"></div>
328  <div class="il-system-infos"></div>
329  <div class="nav il-maincontrols">MainBar Stub</div>
330  <!-- html5 main-tag is not supported in IE / div is needed -->
331  <main class="il-layout-page-content">
332  <div>some content</div>
333  </main>
334  </div>
335  <script>il.Util.addOnLoad(function() {});</script>
336  </body>
337 </html>');
338  $this->assertEquals($exptected, $html);
339  }
metabar()
Definition: metabar.php:2
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
mainbar()
Definition: mainbar.php:2
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testRenderingWithTitle()

StandardPageTest::testRenderingWithTitle ( )

Definition at line 212 of file StandardPageTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), mainbar(), and metabar().

212  : void
213  {
214  $this->stdpage = $this->stdpage
215  ->withTitle("Title")
216  ->withViewTitle("View Title")
217  ->withShortTitle("Short Title");
218 
219  $r = $this->getDefaultRenderer(null, [$this->metabar, $this->mainbar, $this->crumbs, $this->logo]);
220  $html = $this->brutallyTrimHTML($r->render($this->stdpage));
221 
222  $exptected = $this->brutallyTrimHTML('
223 <!DOCTYPE html>
224 <html lang="en" dir="ltr">
225  <head>
226  <meta charset="utf-8" />
227  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
228  <meta name="viewport" content="width=device-width, initial-scale=1" />
229  <title>Short Title: View Title</title>
230  <style></style>
231  </head>
232  <body>
233  <div class="il-layout-page">
234  <header>
235  <div class="header-inner">
236  <div class="il-logo">
237  <span class="hidden-xs">Logo Stub</span>
238  <span class="visible-xs">Responsive Logo Stub</span>
239  <div class="il-pagetitle">Title</div>
240  </div>MetaBar Stub
241  </div>
242  </header>
243  <div class="breadcrumbs"></div>
244  <div class="il-system-infos"></div>
245  <div class="nav il-maincontrols">MainBar Stub</div>
246  <!-- html5 main-tag is not supported in IE / div is needed -->
247  <main class="il-layout-page-content">
248  <div>some content</div>
249  </main>
250  </div>
251  <script>il.Util.addOnLoad(function() {});</script>
252  </body>
253 </html>');
254  $this->assertEquals($exptected, $html);
255  }
metabar()
Definition: metabar.php:2
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
mainbar()
Definition: mainbar.php:2
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testWithMetaDatum()

StandardPageTest::testWithMetaDatum ( )

Definition at line 201 of file StandardPageTest.php.

202  {
203  $meta_datum_key = 'meta_datum_key';
204  $meta_datum_value = 'meta_datum_value';
205  $meta_data = [$meta_datum_key => $meta_datum_value];
206  $this->assertEquals(
207  $meta_data,
208  $this->stdpage->withAdditionalMetaDatum($meta_datum_key, $meta_datum_value)->getMetaData()
209  );
210  }

◆ testWithShortTitle()

StandardPageTest::testWithShortTitle ( )

Definition at line 173 of file StandardPageTest.php.

173  : void
174  {
175  $title = 'some short title';
176  $this->assertEquals(
177  $title,
178  $this->stdpage->withShortTitle($title)->getShortTitle()
179  );
180  }

◆ testWithTextDirection()

StandardPageTest::testWithTextDirection ( )

Definition at line 190 of file StandardPageTest.php.

190  : void
191  {
192  $this->assertEquals("ltr", $this->stdpage->getTextDirection());
193  $this->assertEquals(
194  "rtl",
195  $this->stdpage
196  ->withTextDirection($this->stdpage::RTL)
197  ->getTextDirection()
198  );
199  }

◆ testWithTitle()

StandardPageTest::testWithTitle ( )

Definition at line 165 of file StandardPageTest.php.

165  : void
166  {
167  $title = 'some title';
168  $this->assertEquals(
169  $title,
170  $this->stdpage->withTitle($title)->getTitle()
171  );
172  }

◆ testWithViewTitle()

StandardPageTest::testWithViewTitle ( )

Definition at line 181 of file StandardPageTest.php.

181  : void
182  {
183  $title = 'some view title';
184  $this->assertEquals(
185  $title,
186  $this->stdpage->withViewTitle($title)->getViewTitle()
187  );
188  }

◆ testWithWrongContents()

StandardPageTest::testWithWrongContents ( )

Definition at line 145 of file StandardPageTest.php.

References mainbar(), and metabar().

145  : void
146  {
147  $this->expectException(TypeError::class);
148  $this->stdpage = $this->factory->standard(
149  $this->metabar,
150  $this->mainbar,
151  'string is not allowed here',
152  $this->crumbs,
153  $this->logo
154  );
155  }
metabar()
Definition: metabar.php:2
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

Field Documentation

◆ $crumbs

StandardPageTest::$crumbs
protected

Definition at line 44 of file StandardPageTest.php.

◆ $factory

StandardPageTest::$factory
protected

Definition at line 29 of file StandardPageTest.php.

◆ $logo

StandardPageTest::$logo
protected

Definition at line 49 of file StandardPageTest.php.

◆ $mainbar

StandardPageTest::$mainbar
protected

Definition at line 34 of file StandardPageTest.php.

◆ $metabar

StandardPageTest::$metabar
protected

Definition at line 39 of file StandardPageTest.php.

◆ $stdpage

StandardPageTest::$stdpage
protected

Definition at line 24 of file StandardPageTest.php.


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