ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ToastClientHtmlTest.php
Go to the documentation of this file.
1<?php
2
19require_once("vendor/composer/vendor/autoload.php");
20
21require_once(__DIR__ . "/../../Base.php");
22
25
27{
28 public function getUIFactory(): NoUIFactory
29 {
30 return new class () extends NoUIFactory {
31 public function button(): I\Component\Button\Factory
32 {
33 return new I\Component\Button\Factory();
34 }
35 };
36 }
37
38 public function getToastFactory(): \ILIAS\UI\Implementation\Component\Toast\Factory
39 {
41 $this->createMock(ILIAS\UI\Implementation\Component\SignalGenerator::class)
42 );
43 }
44
45 public function getIconFactory(): \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory
46 {
48 }
49
50 public function testRenderClientHtml(): void
51 {
52 $expected_html = file_get_contents(__DIR__ . "/../../Client/Toast/ToastTest.html");
53
54 $rendered_html = '<head>
55 <title>Toast Test HTML</title>
56 <script src="../../../resources/js/Toast/toast.js"></script>
57 <script>document.il = il</script>
58 </head>
59 <body>
60 {CONTAINER}
61 </body>';
62
63 $container = $this->getToastFactory()->container()->withAdditionalToast(
64 $this->getToastFactory()->standard(
65 'Title',
66 $this->getIconFactory()->standard('mail', 'Test')
67 )
68 ->withDescription('Description')
69 ->withAction('https://www.ilias.de')
70 );
71
72 $rendered_html = str_replace('{CONTAINER}', $this->getDefaultRenderer()->render($container), $rendered_html);
73 $rendered_html = preg_replace('/id=".*?"/', '', $rendered_html);
74
75 $this->assertEquals($this->brutallyTrimHTML($expected_html), $this->brutallyTrimHTML($rendered_html));
76 }
77}
Provides common functionality for UI tests.
Definition: Base.php:337
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withAction(URI|Signal|string $action)
button(string $caption, string $cmd)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$container
@noRector
Definition: wac.php:37