ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ToastClientHtmlTest.php
Go to the documentation of this file.
1 <?php
18 require_once("libs/composer/vendor/autoload.php");
19 
20 require_once(__DIR__ . "/../../Base.php");
21 
22 use ILIAS\UI\Component as C;
24 
26 {
27  public function getUIFactory(): NoUIFactory
28  {
29  return new class () extends NoUIFactory {
30  public function button(): C\Button\Factory
31  {
32  return new I\Component\Button\Factory();
33  }
34  };
35  }
36 
38  {
40  $this->createMock(ILIAS\UI\Implementation\Component\SignalGenerator::class)
41  );
42  }
43 
44  public function getIconFactory(): \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory
45  {
47  }
48 
49  public function testRenderClientHtml(): void
50  {
51  $expected_html = file_get_contents(__DIR__ . "/../../Client/Toast/ToastTest.html");
52 
53  $rendered_html = '<head>
54  <title>Toast Test HTML</title>
55  <script src="../../../../src/UI/templates/js/Toast/toast.js"></script>
56  <script>document.il = il</script>
57  </head>
58  <body>
59  {CONTAINER}
60  </body>';
61 
62  $container = $this->getToastFactory()->container()->withAdditionalToast(
63  $this->getToastFactory()->standard(
64  'Title',
65  $this->getIconFactory()->standard('mail', 'Test')
66  )
67  ->withVanishTime(5000)
68  ->withDelayTime(500)
69  ->withDescription('Description')
70  ->withAction('https://www.ilias.de')
71  );
72 
73  $rendered_html = str_replace('{CONTAINER}', $this->getDefaultRenderer()->render($container), $rendered_html);
74  $rendered_html = preg_replace('/id=".*?"/', '', $rendered_html);
75 
76  $this->assertEquals($this->brutallyTrimHTML($expected_html), $this->brutallyTrimHTML($rendered_html));
77  }
78 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class Factory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
standard()
This is an example, of how the Notification Slate is generated by assigning Notification Items to it...
Definition: standard.php:16
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
$container
Definition: wac.php:14
Provides common functionality for UI tests.
Definition: Base.php:298
This is how the factory for UI elements looks.
Definition: Factory.php:37