ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
LightboxTest Class Reference

Tests on implementation for the lightbox modal. More...

+ Inheritance diagram for LightboxTest:
+ Collaboration diagram for LightboxTest:

Public Member Functions

 testGetSinglePage ()
 
 testGetMultiplePage ()
 
 testSimplePageRendering (string $method, array $args, string $expected_html)
 getPageProvider More...
 
 getPageProvider ()
 
 testDifferentPageTypeRendering ()
 
- Public Member Functions inherited from ModalBase
 getUIFactory ()
 
 normalizeHTML (string $html)
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 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 Member Functions

 getLightboxPage ()
 
 getExpectedTextPageHTML ()
 
 getExpectedImagePageHTML ()
 
 getExpectedMixedPagesHTML ()
 
- Protected Member Functions inherited from ModalBase
 getModalFactory ()
 
 getButtonFactory ()
 
 getDummyComponent ()
 
- 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...
 

Private Member Functions

 getExpectedCardPageHTML ()
 

Detailed Description

Tests on implementation for the lightbox modal.

Author
Stefan Wanzenried sw@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 31 of file LightboxTest.php.

Member Function Documentation

◆ getExpectedCardPageHTML()

LightboxTest::getExpectedCardPageHTML ( )
private

Definition at line 331 of file LightboxTest.php.

References ILIAS\Repository\button(), and Vendor\Package\foo().

Referenced by getPageProvider().

331  : string
332  {
333  return <<<EOT
334 <div class="modal fade il-modal-lightbox il-modal-lightbox-bright" tabindex="-1" role="dialog" id="id_1">
335  <div class="modal-dialog modal-lg" role="document">
336  <div class="modal-content il-modal-lightbox-page">
337  <div class="modal-header">
338  <button type="button" class="close" data-dismiss="modal" aria-label="close">
339  <span aria-hidden="true"></span>
340  </button>
341  <h1 class="modal-title">
342  foo
343  </h1>
344  </div>
345  <div class="modal-body">
346  <div id="id_1_carousel" class="carousel slide" data-ride="carousel" data-interval="false">
347  <div class="carousel-inner" role="listbox">
348  <div class="item active" data-title="foo">
349  <div class="item-content item-vertical"></div>
350  </div>
351  </div>
352  </div>
353  </div>
354  </div>
355  </div>
356 </div>
357 <script>
358 document.addEventListener('DOMContentLoaded', function() {
359  $('#id_1').on('shown.bs.modal', function() {
360  $('.modal-backdrop.in').css('opacity', '0.9');
361  });
362  $('#id_1').on('show.bs.modal', function (e) {
363  var elm = $(this).find('.carousel-inner .item.active').first();
364  if (elm.hasClass('text-only')) {
365  elm.closest('.carousel').addClass('text-only');
366  } else {
367  elm.closest('.carousel').removeClass('text-only');
368  }
369  });
370  $('#id_1_carousel').on('slide.bs.carousel', function(e) {
371  var elm = $(e.relatedTarget);
372  if (elm.hasClass('text-only')) {
373  elm.closest('.carousel').addClass('text-only');
374  } else {
375  elm.closest('.carousel').removeClass('text-only');
376  }
377  });
378  $('#id_1_carousel').on('slid.bs.carousel', function() {
379  var title = $(this).find('.carousel-inner .item.active').attr('data-title');
380  $('#id_1').find('.modal-title').text(title);
381  });
382 });
383 </script>
384 EOT;
385  }
button(string $caption, string $cmd)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpectedImagePageHTML()

LightboxTest::getExpectedImagePageHTML ( )
protected

Definition at line 155 of file LightboxTest.php.

References ILIAS\Repository\button().

Referenced by getPageProvider().

155  : string
156  {
157  return <<<EOT
158 <div class="modal fade il-modal-lightbox il-modal-lightbox-dark" tabindex="-1" role="dialog" id="id_1">
159  <div class="modal-dialog modal-lg" role="document">
160  <div class="modal-content il-modal-lightbox-page">
161  <div class="modal-header">
162  <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button>
163  <h1 class="modal-title">title</h1>
164  </div>
165  <div class="modal-body">
166  <div id="id_1_carousel" class="carousel slide" data-ride="carousel" data-interval="false">
167 
168 
169 
170  <div class="carousel-inner" role="listbox">
171 
172  <div class="item active" data-title="title">
173  <div class="item-content ">
174 
175 
176 
177 
178 
179 <img src="src/fake/image.jpg" class="img-responsive" alt="description" />
180 
181 
182 
183  </div>
184 
185  <div class="carousel-caption">
186  description
187  </div>
188  </div>
189 
190  </div>
191 
192 
193 
194  </div>
195  </div>
196  </div>
197  </div>
198 </div>
199 <script>
200  document.addEventListener('DOMContentLoaded', function() {
201  $('#id_1').on('shown.bs.modal', function() {
202  $('.modal-backdrop.in').css('opacity', '0.9');
203  });
204  $('#id_1').on('show.bs.modal', function (e) {
205  var elm = $(this).find('.carousel-inner .item.active').first();
206 
207  if (elm.hasClass('text-only')) {
208  elm.closest('.carousel').addClass('text-only');
209  } else {
210  elm.closest('.carousel').removeClass('text-only');
211  }
212  });
213  $('#id_1_carousel').on('slide.bs.carousel', function(e) {
214  var elm = $(e.relatedTarget);
215 
216  if (elm.hasClass('text-only')) {
217  elm.closest('.carousel').addClass('text-only');
218  } else {
219  elm.closest('.carousel').removeClass('text-only');
220  }
221  });
222  $('#id_1_carousel').on('slid.bs.carousel', function() {
223  var title = $(this).find('.carousel-inner .item.active').attr('data-title');
224  $('#id_1').find('.modal-title').text(title);
225  });
226  });
227 </script>
228 EOT;
229  }
button(string $caption, string $cmd)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpectedMixedPagesHTML()

LightboxTest::getExpectedMixedPagesHTML ( )
protected

Definition at line 231 of file LightboxTest.php.

References ILIAS\Repository\button(), and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\to().

Referenced by testDifferentPageTypeRendering().

231  : string
232  {
233  return <<<EOT
234 <div class="modal fade il-modal-lightbox il-modal-lightbox-dark" tabindex="-1" role="dialog" id="id_1">
235  <div class="modal-dialog modal-lg" role="document">
236  <div class="modal-content il-modal-lightbox-page">
237  <div class="modal-header">
238  <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button>
239  <h1 class="modal-title">title</h1>
240  </div>
241  <div class="modal-body">
242  <div id="id_1_carousel" class="carousel slide" data-ride="carousel" data-interval="false">
243 
244 
245  <ol class="carousel-indicators">
246 
247  <li data-target="#id_1_carousel" data-slide-to="0" class="active"></li>
248 
249  <li data-target="#id_1_carousel" data-slide-to="1" class=""></li>
250 
251  </ol>
252 
253 
254  <div class="carousel-inner" role="listbox">
255 
256  <div class="item active text-only" data-title="title">
257  <div class="item-content ">
258  HelloWorld
259  </div>
260 
261  </div>
262 
263  <div class="item " data-title="title">
264  <div class="item-content ">
265 
266 
267 
268 
269 
270 <img src="src/fake/image.jpg" class="img-responsive" alt="description" />
271 
272 
273 
274  </div>
275 
276  <div class="carousel-caption">
277  description
278  </div>
279  </div>
280 
281  </div>
282 
283 
284  <a class="left carousel-control" href="#id_1_carousel" role="button" data-slide="prev">
285  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
286  <span class="sr-only">Previous</span>
287  </a>
288  <a class="right carousel-control" href="#id_1_carousel" role="button" data-slide="next">
289  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
290  <span class="sr-only">Next</span>
291  </a>
292 
293 
294  </div>
295  </div>
296  </div>
297  </div>
298 </div>
299 <script>
300  document.addEventListener('DOMContentLoaded', function() {
301  $('#id_1').on('shown.bs.modal', function() {
302  $('.modal-backdrop.in').css('opacity', '0.9');
303  });
304  $('#id_1').on('show.bs.modal', function (e) {
305  var elm = $(this).find('.carousel-inner .item.active').first();
306 
307  if (elm.hasClass('text-only')) {
308  elm.closest('.carousel').addClass('text-only');
309  } else {
310  elm.closest('.carousel').removeClass('text-only');
311  }
312  });
313  $('#id_1_carousel').on('slide.bs.carousel', function(e) {
314  var elm = $(e.relatedTarget);
315 
316  if (elm.hasClass('text-only')) {
317  elm.closest('.carousel').addClass('text-only');
318  } else {
319  elm.closest('.carousel').removeClass('text-only');
320  }
321  });
322  $('#id_1_carousel').on('slid.bs.carousel', function() {
323  var title = $(this).find('.carousel-inner .item.active').attr('data-title');
324  $('#id_1').find('.modal-title').text(title);
325  });
326  });
327 </script>
328 EOT;
329  }
button(string $caption, string $cmd)
to(\GdImage $image, int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.
Some very basic component implementation.
Definition: HelloWorld.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpectedTextPageHTML()

LightboxTest::getExpectedTextPageHTML ( )
protected

Definition at line 90 of file LightboxTest.php.

References ILIAS\Repository\button().

Referenced by getPageProvider().

90  : string
91  {
92  return <<<EOT
93 <div class="modal fade il-modal-lightbox il-modal-lightbox-bright" tabindex="-1" role="dialog" id="id_1">
94  <div class="modal-dialog modal-lg" role="document">
95  <div class="modal-content il-modal-lightbox-page">
96  <div class="modal-header">
97  <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button>
98  <h1 class="modal-title">title</h1>
99  </div>
100  <div class="modal-body">
101  <div id="id_1_carousel" class="carousel slide" data-ride="carousel" data-interval="false">
102 
103 
104 
105  <div class="carousel-inner" role="listbox">
106 
107  <div class="item active text-only" data-title="title">
108  <div class="item-content ">
109  HelloWorld
110  </div>
111 
112  </div>
113 
114  </div>
115 
116 
117 
118  </div>
119  </div>
120  </div>
121  </div>
122 </div>
123 <script>
124  document.addEventListener('DOMContentLoaded', function() {
125  $('#id_1').on('shown.bs.modal', function() {
126  $('.modal-backdrop.in').css('opacity', '0.9');
127  });
128  $('#id_1').on('show.bs.modal', function (e) {
129  var elm = $(this).find('.carousel-inner .item.active').first();
130 
131  if (elm.hasClass('text-only')) {
132  elm.closest('.carousel').addClass('text-only');
133  } else {
134  elm.closest('.carousel').removeClass('text-only');
135  }
136  });
137  $('#id_1_carousel').on('slide.bs.carousel', function(e) {
138  var elm = $(e.relatedTarget);
139 
140  if (elm.hasClass('text-only')) {
141  elm.closest('.carousel').addClass('text-only');
142  } else {
143  elm.closest('.carousel').removeClass('text-only');
144  }
145  });
146  $('#id_1_carousel').on('slid.bs.carousel', function() {
147  var title = $(this).find('.carousel-inner .item.active').attr('data-title');
148  $('#id_1').find('.modal-title').text(title);
149  });
150  });
151 </script>
152 EOT;
153  }
button(string $caption, string $cmd)
Some very basic component implementation.
Definition: HelloWorld.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLightboxPage()

LightboxTest::getLightboxPage ( )
protected

Definition at line 85 of file LightboxTest.php.

Referenced by testGetMultiplePage(), and testGetSinglePage().

86  {
87  return new LightboxMockPage();
88  }
+ Here is the caller graph for this function:

◆ getPageProvider()

LightboxTest::getPageProvider ( )

Definition at line 58 of file LightboxTest.php.

References getExpectedCardPageHTML(), getExpectedImagePageHTML(), and getExpectedTextPageHTML().

58  : array
59  {
60  $image = new I\Component\Image\Image("responsive", 'src/fake/image.jpg', 'description');
61  $card = new I\Component\Card\Card('foo');
62 
63  return [
64  'Render image page' => ['lightboxImagePage', [$image, 'title'], $this->getExpectedImagePageHTML()],
65  'Render text page' => ['lightboxTextPage', ['HelloWorld', 'title'], $this->getExpectedTextPageHTML()],
66  'Render card page' => ['lightboxCardPage', [$card], $this->getExpectedCardPageHTML()],
67  ];
68  }
getExpectedImagePageHTML()
getExpectedTextPageHTML()
+ Here is the call graph for this function:

◆ testDifferentPageTypeRendering()

LightboxTest::testDifferentPageTypeRendering ( )

Definition at line 70 of file LightboxTest.php.

References ILIAS_UI_TestBase\getDefaultRenderer(), getExpectedMixedPagesHTML(), ModalBase\getModalFactory(), and ModalBase\normalizeHTML().

70  : void
71  {
72  $image1 = new I\Component\Image\Image("responsive", 'src/fake/image.jpg', 'description');
73 
74  $pages = [
75  $this->getModalFactory()->lightboxTextPage('HelloWorld', 'title'),
76  $this->getModalFactory()->lightboxImagePage($image1, 'title'),
77  ];
78 
79  $lightbox = $this->getModalFactory()->lightbox($pages);
80  $expected = $this->normalizeHTML($this->getExpectedMixedPagesHTML());
81  $actual = $this->normalizeHTML($this->getDefaultRenderer()->render($lightbox));
82  $this->assertEquals($expected, $actual);
83  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getExpectedMixedPagesHTML()
normalizeHTML(string $html)
Definition: ModalBase.php:76
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testGetMultiplePage()

LightboxTest::testGetMultiplePage ( )

Definition at line 40 of file LightboxTest.php.

References getLightboxPage(), and ModalBase\getModalFactory().

40  : void
41  {
42  $pages = [$this->getLightboxPage(), $this->getLightboxPage()];
43  $lightbox = $this->getModalFactory()->lightbox($pages);
44  $this->assertEquals($pages, $lightbox->getPages());
45  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testGetSinglePage()

LightboxTest::testGetSinglePage ( )

Definition at line 33 of file LightboxTest.php.

References getLightboxPage(), and ModalBase\getModalFactory().

33  : void
34  {
35  $page = $this->getLightboxPage();
36  $lightbox = $this->getModalFactory()->lightbox($page);
37  $this->assertEquals([$page], $lightbox->getPages());
38  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testSimplePageRendering()

LightboxTest::testSimplePageRendering ( string  $method,
array  $args,
string  $expected_html 
)

getPageProvider

Definition at line 50 of file LightboxTest.php.

References ILIAS_UI_TestBase\getDefaultRenderer(), ModalBase\getModalFactory(), and ModalBase\normalizeHTML().

50  : void
51  {
52  $lightbox = $this->getModalFactory()->lightbox($this->getModalFactory()->$method(...$args));
53  $expected = $this->normalizeHTML($expected_html);
54  $actual = $this->normalizeHTML($this->getDefaultRenderer()->render($lightbox));
55  $this->assertEquals($expected, $actual);
56  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
normalizeHTML(string $html)
Definition: ModalBase.php:76
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

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