ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
MailPageTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23require_once('vendor/composer/vendor/autoload.php');
24require_once(__DIR__ . '/../../../Base.php');
25
28use ILIAS\Data\Link as DataLink;
32use NoUIFactory;
33
35{
38 protected string $logo;
39 protected string $installation_title;
40 protected string $stylesheet_path;
41 protected URI $uri;
43 protected DataLink $footer_url;
44
45 public function setUp(): void
46 {
47 $this->html_content = $this->createMock(Content::class);
48 $this->html_content->method('getContent')->willReturn('ILIAS HTML Content');
49
50 $this->logo = 'cid:ILIAS Logo';
51 $this->installation_title = 'ILIAS Installation Title';
52 $this->stylesheet_path = __FILE__;
53 $this->uri = $this->createMock(URI::class);
54 $this->uri->method('getBaseURI')->willReturn('ILIAS Link URI');
55 $this->footer_url = $this->createMock(DataLink::class);
56 $this->footer_url->method('getLabel')->willReturn('ILIAS Link Label');
57 $this->footer_url->method('getURL')->willReturn($this->uri);
58
59 $this->factory = new Page\Factory();
60 $this->mailpage = $this->factory->mail(
61 $this->stylesheet_path,
62 $this->logo,
63 $this->installation_title,
64 $this->html_content,
65 $this->footer_url,
66 );
67 }
68
69 public function testConstruction(): void
70 {
71 static::assertInstanceOf(
72 Page\Mail::class,
73 $this->mailpage,
74 );
75 }
76
77 public static function provideGetData(): array
78 {
79 return [
80 ['html_content', 'getContent', 'assertContains'],
81 ['logo', 'getLogoURL', 'assertEquals'],
82 ['installation_title', 'getInstallationTitle', 'assertEquals'],
83 ['stylesheet_path', 'getStyleSheetPath', 'assertEquals'],
84 ['footer_url', 'getFooterURL', 'assertEquals'],
85 ];
86 }
87
91 public function testGet(mixed $expected, string $method_to_call, string $assert_method): void
92 {
93 static::$assert_method(
94 $this->$expected,
95 $this->mailpage->$method_to_call(),
96 );
97 }
98
99 public function testRenderMailPage(): void
100 {
101 $renderer = $this->getDefaultRenderer(null, [$this->html_content]);
102 $mailpage = $this->factory->mail(
103 $this->stylesheet_path,
104 $this->logo,
105 $this->installation_title,
106 $this->html_content,
107 $this->footer_url,
108 );
109
110 $html = $this->brutallyTrimHTML($renderer->render($mailpage));
111 $expected = $this->brutallyTrimHTML('
112<body>
113<table class="table">
114 <tr class="header">
115 <td class="spacing">
116 <table class="w-750 center">
117 <tr class="rowheight"></tr>
118 <tr>
119 <td class="image-data">
120 <img class="logo" src="' . $this->logo . '" alt="Logo">
121 </td>
122 <td class="installation-text">
123 <span>
124 <strong>' . $this->installation_title . '</strong>
125 </span>
126 </td>
127 </tr>
128 <tr class="rowheight"></tr>
129 </table>
130 </td>
131 </tr>
132 <tr class="content">
133 <td class="spacing">
134 <table class="w-750 center">
135 <tr class="headerheight"></tr>
136 <tr>
137 <td class="font-definition">
138 ' . $renderer->render($this->html_content) . '
139 </td>
140 </tr>
141 <tr class="headerheight"></tr>
142 </table>
143 </td>
144 </tr>
145 <tr class="footer">
146 <td class="spacing">
147 <table class="w-750 center">
148 <tr>
149 <td class="font-definition">
150 <span>' . $this->installation_title . '</span>
151 <br>
152 <a href="ILIAS Link URI">ILIAS Link Label</a>
153 </td>
154 </tr>
155 </table>
156 </td>
157 </tr>
158</table>
159</body>');
160
161 static::assertStringContainsString($expected, $html);
162 }
163
164 public function getUIFactory(): NoUIFactory
165 {
166 return new class () extends NoUIFactory {
167 public function link(): Link\Factory
168 {
169 return new Link\Factory();
170 }
171 };
172 }
173}
factory()
$renderer
testGet(mixed $expected, string $method_to_call, string $assert_method)
@dataProvider provideGetData
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Provides common functionality for UI tests.
Definition: Base.php:337
This describes the Mail.
Definition: Mail.php:27
This describes the Page.
Definition: Page.php:31
link(string $caption, string $href, bool $new_viewport=false)