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