ILIAS  release_8 Revision v8.24
ilFormFieldParserTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 public function testA4(): void
27 {
28 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
29 ->getMock();
30
31 $content = '';
32
33 $parser = new ilFormFieldParser($xlstProcess);
34 $formFields = $parser->fetchDefaultFormFields($content);
35
36 $this->assertSame(
37 [
38 'pageformat' => 'a4',
39 'pagewidth' => '21cm',
40 'pageheight' => '29.7cm',
41 'margin_body_top' => '0cm',
42 'margin_body_right' => '2cm',
43 'margin_body_bottom' => '0cm',
44 'margin_body_left' => '2cm',
45 'certificate_text' => ''
46 ],
47 $formFields
48 );
49 }
50
51 public function testCustomPageWidth(): void
52 {
53 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
54 ->getMock();
55
56 $xlstProcess
57 ->expects($this->once())
58 ->method('process');
59
60 $content = 'page-width="210mm" page-height="310mm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
61
62 $parser = new ilFormFieldParser($xlstProcess);
63 $formFields = $parser->fetchDefaultFormFields($content);
64
65 $this->assertSame(
66 [
67 'pageformat' => 'custom',
68 'pagewidth' => '210mm',
69 'pageheight' => '310mm',
70 'margin_body_top' => '1cm',
71 'margin_body_right' => '2cm',
72 'margin_body_bottom' => '3cm',
73 'margin_body_left' => '4cm',
74 'certificate_text' => ''
75 ],
76 $formFields
77 );
78 }
79
80 public function testA5(): void
81 {
82 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
83 ->getMock();
84
85 $xlstProcess
86 ->expects($this->once())
87 ->method('process');
88
89 $content = 'page-width="14.8cm" page-height="21cm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
90
91 $parser = new ilFormFieldParser($xlstProcess);
92 $formFields = $parser->fetchDefaultFormFields($content);
93
94 $this->assertSame(
95 [
96 'pageformat' => 'a5',
97 'pagewidth' => '14.8cm',
98 'pageheight' => '21cm',
99 'margin_body_top' => '1cm',
100 'margin_body_right' => '2cm',
101 'margin_body_bottom' => '3cm',
102 'margin_body_left' => '4cm',
103 'certificate_text' => ''
104 ],
105 $formFields
106 );
107 }
108
109 public function testA5Landscape(): void
110 {
111 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
112 ->getMock();
113
114 $xlstProcess
115 ->expects($this->once())
116 ->method('process');
117
118 $content = 'page-width="21cm" page-height="14.8cm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
119
120 $parser = new ilFormFieldParser($xlstProcess);
121 $formFields = $parser->fetchDefaultFormFields($content);
122
123 $this->assertSame(
124 [
125 'pageformat' => 'a5landscape',
126 'pagewidth' => '21cm',
127 'pageheight' => '14.8cm',
128 'margin_body_top' => '1cm',
129 'margin_body_right' => '2cm',
130 'margin_body_bottom' => '3cm',
131 'margin_body_left' => '4cm',
132 'certificate_text' => ''
133 ],
134 $formFields
135 );
136 }
137
138 public function testA4Landscape(): void
139 {
140 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
141 ->getMock();
142
143 $xlstProcess
144 ->expects($this->once())
145 ->method('process');
146
147 $content = 'page-width="29.7cm" page-height="21cm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
148
149 $parser = new ilFormFieldParser($xlstProcess);
150 $formFields = $parser->fetchDefaultFormFields($content);
151
152 $this->assertSame(
153 [
154 'pageformat' => 'a4landscape',
155 'pagewidth' => '29.7cm',
156 'pageheight' => '21cm',
157 'margin_body_top' => '1cm',
158 'margin_body_right' => '2cm',
159 'margin_body_bottom' => '3cm',
160 'margin_body_left' => '4cm',
161 'certificate_text' => ''
162 ],
163 $formFields
164 );
165 }
166
167 public function testLetterLandscape(): void
168 {
169 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
170 ->getMock();
171
172 $xlstProcess
173 ->expects($this->once())
174 ->method('process');
175
176 $content = 'page-width="11in" page-height="8.5in" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
177
178 $parser = new ilFormFieldParser($xlstProcess);
179 $formFields = $parser->fetchDefaultFormFields($content);
180
181 $this->assertSame(
182 [
183 'pageformat' => 'letterlandscape',
184 'pagewidth' => '11in',
185 'pageheight' => '8.5in',
186 'margin_body_top' => '1cm',
187 'margin_body_right' => '2cm',
188 'margin_body_bottom' => '3cm',
189 'margin_body_left' => '4cm',
190 'certificate_text' => ''
191 ],
192 $formFields
193 );
194 }
195
196 public function testLetter(): void
197 {
198 $xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
199 ->getMock();
200
201 $xlstProcess
202 ->expects($this->once())
203 ->method('process');
204
205 $content = 'page-width="8.5in" page-height="11in" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
206
207 $parser = new ilFormFieldParser($xlstProcess);
208 $formFields = $parser->fetchDefaultFormFields($content);
209
210 $this->assertSame(
211 [
212 'pageformat' => 'letter',
213 'pagewidth' => '8.5in',
214 'pageheight' => '11in',
215 'margin_body_top' => '1cm',
216 'margin_body_right' => '2cm',
217 'margin_body_bottom' => '3cm',
218 'margin_body_left' => '4cm',
219 'certificate_text' => ''
220 ],
221 $formFields
222 );
223 }
224}
Class ilCertificateBaseTestCase.