ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilFormFieldParserTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
9 public function testA4()
10 {
11 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
12 ->getMock();
13
14 $content = '';
15
16 $parser = new ilFormFieldParser($xlstProcess);
17 $formFields = $parser->fetchDefaultFormFields($content);
18
19 $this->assertEquals(
20 array(
21 'pageformat' => 'a4',
22 'pagewidth' => '21cm',
23 'pageheight' => '29.7cm',
24 'margin_body_top' => '0cm',
25 'margin_body_right' => '2cm',
26 'margin_body_bottom' => '0cm',
27 'margin_body_left' => '2cm',
28 'certificate_text' => ''
29 ),
30 $formFields
31 );
32 }
33
34 public function testCustomPageWidth()
35 {
36 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
37 ->getMock();
38
39 $xlstProcess
40 ->expects($this->once())
41 ->method('process');
42
43 $content = 'page-width="210mm" page-height="310mm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
44
45 $parser = new ilFormFieldParser($xlstProcess);
46 $formFields = $parser->fetchDefaultFormFields($content);
47
48 $this->assertEquals(
49 array(
50 'pageformat' => 'custom',
51 'pagewidth' => '210mm',
52 'pageheight' => '310mm',
53 'margin_body_top' => '1cm',
54 'margin_body_right' => '2cm',
55 'margin_body_bottom' => '3cm',
56 'margin_body_left' => '4cm',
57 'certificate_text' => ''
58 ),
59 $formFields
60 );
61 }
62
63 public function testA5()
64 {
65 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
66 ->getMock();
67
68 $xlstProcess
69 ->expects($this->once())
70 ->method('process');
71
72 $content = 'page-width="14.8cm" page-height="21cm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
73
74 $parser = new ilFormFieldParser($xlstProcess);
75 $formFields = $parser->fetchDefaultFormFields($content);
76
77 $this->assertEquals(
78 array(
79 'pageformat' => 'a5',
80 'pagewidth' => '14.8cm',
81 'pageheight' => '21cm',
82 'margin_body_top' => '1cm',
83 'margin_body_right' => '2cm',
84 'margin_body_bottom' => '3cm',
85 'margin_body_left' => '4cm',
86 'certificate_text' => ''
87 ),
88 $formFields
89 );
90 }
91
92 public function testA5Landscape()
93 {
94 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
95 ->getMock();
96
97 $xlstProcess
98 ->expects($this->once())
99 ->method('process');
100
101 $content = 'page-width="21cm" page-height="14.8cm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
102
103 $parser = new ilFormFieldParser($xlstProcess);
104 $formFields = $parser->fetchDefaultFormFields($content);
105
106 $this->assertEquals(
107 array(
108 'pageformat' => 'a5landscape',
109 'pagewidth' => '21cm',
110 'pageheight' => '14.8cm',
111 'margin_body_top' => '1cm',
112 'margin_body_right' => '2cm',
113 'margin_body_bottom' => '3cm',
114 'margin_body_left' => '4cm',
115 'certificate_text' => ''
116 ),
117 $formFields
118 );
119 }
120
121 public function testA4Landscape()
122 {
123 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
124 ->getMock();
125
126 $xlstProcess
127 ->expects($this->once())
128 ->method('process');
129
130 $content = 'page-width="29.7cm" page-height="21cm" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
131
132 $parser = new ilFormFieldParser($xlstProcess);
133 $formFields = $parser->fetchDefaultFormFields($content);
134
135 $this->assertEquals(
136 array(
137 'pageformat' => 'a4landscape',
138 'pagewidth' => '29.7cm',
139 'pageheight' => '21cm',
140 'margin_body_top' => '1cm',
141 'margin_body_right' => '2cm',
142 'margin_body_bottom' => '3cm',
143 'margin_body_left' => '4cm',
144 'certificate_text' => ''
145 ),
146 $formFields
147 );
148 }
149
150 public function testLetterLandscape()
151 {
152 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
153 ->getMock();
154
155 $xlstProcess
156 ->expects($this->once())
157 ->method('process');
158
159 $content = 'page-width="11in" page-height="8.5in" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
160
161 $parser = new ilFormFieldParser($xlstProcess);
162 $formFields = $parser->fetchDefaultFormFields($content);
163
164 $this->assertEquals(
165 array(
166 'pageformat' => 'letterlandscape',
167 'pagewidth' => '11in',
168 'pageheight' => '8.5in',
169 'margin_body_top' => '1cm',
170 'margin_body_right' => '2cm',
171 'margin_body_bottom' => '3cm',
172 'margin_body_left' => '4cm',
173 'certificate_text' => ''
174 ),
175 $formFields
176 );
177 }
178
179 public function testLetter()
180 {
181 $xlstProcess = $this->getMockBuilder('ilCertificateXlstProcess')
182 ->getMock();
183
184 $xlstProcess
185 ->expects($this->once())
186 ->method('process');
187
188 $content = 'page-width="8.5in" page-height="11in" <fo:region-body margin="1cm 2cm 3cm 4cm"/>';
189
190 $parser = new ilFormFieldParser($xlstProcess);
191 $formFields = $parser->fetchDefaultFormFields($content);
192
193 $this->assertEquals(
194 array(
195 'pageformat' => 'letter',
196 'pagewidth' => '8.5in',
197 'pageheight' => '11in',
198 'margin_body_top' => '1cm',
199 'margin_body_right' => '2cm',
200 'margin_body_bottom' => '3cm',
201 'margin_body_left' => '4cm',
202 'certificate_text' => ''
203 ),
204 $formFields
205 );
206 }
207}
$parser
Definition: BPMN2Parser.php:23
An exception for terminatinating execution or to throw for unit testing.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.