19 declare(strict_types=1);
31 private const COOKIE_STRING =
'--cookie "PHPSESSID" "" --cookie "ilClientId" "1" ';
34 protected string $default_start =
' --zoom 1 --enable-external-links --disable-forms ';
35 protected string $default_end =
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
37 protected string $second_quiet =
'--quiet --cookie "PHPSESSID" "" --cookie "ilClientId" "1" ';
39 protected function setUp(): void
41 if (!defined(
'CLIENT_ID')) {
42 define(
'CLIENT_ID',
'1');
49 $this->assertInstanceOf(
'ilWkhtmlToPdfConfig', $this->config);
54 $this->assertFalse($this->config->getEnabledForms());
55 $this->assertTrue($this->config->getExternalLinks());
56 $this->assertSame(500, $this->config->getJavascriptDelay());
57 $this->assertSame(1.0, $this->config->getZoom());
58 $this->assertSame(
'Portrait', $this->config->getOrientation());
59 $this->assertSame(
'A4', $this->config->getPageSize());
60 $this->assertSame(
'0.5cm', $this->config->getMarginLeft());
61 $this->assertSame(
'2cm', $this->config->getMarginRight());
62 $this->assertSame(
'0.5cm', $this->config->getMarginBottom());
63 $this->assertSame(
'2cm', $this->config->getMarginTop());
68 $cmd =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
70 $this->assertSame($cmd, $this->config->getCommandLineConfig());
75 $this->config->setOrientation(
'Portrait');
76 $this->config->setPageSize(
'A1');
77 $this->config->setZoom(0.5);
78 $this->config->setJavascriptDelay(500);
79 $this->config->setMarginLeft(
'2');
80 $this->config->setMarginRight(
'2');
81 $this->config->setMarginTop(
'2');
82 $this->config->setMarginBottom(
'2');
83 $exp =
" --zoom 0.5 --enable-external-links --disable-forms --orientation Portrait --page-size 'A1' --javascript-delay 500 --margin-bottom '2' --margin-left '2' --margin-right '2' --margin-top '2' --quiet " . self::COOKIE_STRING;
84 $this->assertSame($exp, $this->config->getCommandLineConfig());
90 $this->assertSame($exp, $this->config->getCommandLineConfig());
95 $this->config->setGreyscale(
true);
97 $this->assertSame($exp, $this->config->getCommandLineConfig());
103 $this->config->setHeaderTextLeft(
'Left');
104 $this->config->setHeaderTextCenter(
'Center');
105 $this->config->setHeaderTextRight(
'Right');
106 $this->config->setHeaderTextSpacing(2);
107 $exp = $this->default_start .
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --header-left 'Left' --header-center 'Center' --header-right 'Right' --header-spacing 2 --quiet --cookie \"PHPSESSID\" \"\" --cookie \"ilClientId\" \"1\" ";
108 $this->assertSame($exp, $this->config->getCommandLineConfig());
114 $this->config->setHeaderHtml(
'<div><b>Test</b></div>');
115 $this->config->setHeaderHtmlSpacing(2);
116 $exp = $this->default_start .
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --header-html '<div><b>Test</b></div>' --header-spacing 2 --quiet " . self::COOKIE_STRING;
117 $this->assertSame($exp, $this->config->getCommandLineConfig());
123 $this->config->setHeaderHtml(
'<div><b>Test</b></div>');
124 $this->config->setHeaderHtmlSpacing(1);
125 $this->config->setHeaderTextLeft(
'Left');
126 $this->config->setHeaderTextCenter(
'Center');
127 $this->config->setHeaderTextRight(
'Right');
128 $exp = $this->default_start .
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --header-html '<div><b>Test</b></div>' --header-spacing 1 --quiet " . self::COOKIE_STRING;
129 $this->assertSame($exp, $this->config->getCommandLineConfig());
135 $this->config->setFooterTextLeft(
'Left');
136 $this->config->setFooterTextCenter(
'Center');
137 $this->config->setFooterTextRight(
'Right');
138 $this->config->setFooterTextSpacing(2);
139 $exp = $this->default_start .
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --footer-left 'Left' --footer-center 'Center' --footer-right 'Right' --footer-spacing 2 --quiet " . self::COOKIE_STRING;
140 $this->assertSame($exp, $this->config->getCommandLineConfig());
146 $this->config->setFooterHtml(
'<div><b>Test</b></div>');
147 $this->config->setFooterHtmlSpacing(2);
148 $exp = $this->default_start .
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --footer-html '<div><b>Test</b></div>' --footer-spacing 2 --quiet " . self::COOKIE_STRING;
149 $this->assertSame($exp, $this->config->getCommandLineConfig());
155 $this->config->setFooterHtml(
'<div><b>Test</b></div>');
156 $this->config->setFooterHtmlLine(
true);
157 $this->config->setFooterHtmlSpacing(1);
158 $exp = $this->default_start .
"--orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --footer-html '<div><b>Test</b></div>' --footer-spacing 1 --footer-line --quiet " . self::COOKIE_STRING;
159 $this->assertSame($exp, $this->config->getCommandLineConfig());
164 $this->config->setEnabledForms(
true);
165 $exp =
" --zoom 1 --enable-external-links --enable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
166 $this->assertSame($exp, $this->config->getCommandLineConfig());
171 $this->config->setExternalLinks(
true);
172 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
173 $this->assertSame($exp, $this->config->getCommandLineConfig());
178 $this->config->setLowQuality(
true);
179 $exp =
" --zoom 1 --enable-external-links --disable-forms --lowquality --orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
180 $this->assertSame($exp, $this->config->getCommandLineConfig());
183 protected string $default_margin_args =
"--margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' ";
187 $this->config->setPrintMediaType(
true);
188 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --print-media-type --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
189 $this->assertSame($exp, $this->config->getCommandLineConfig());
194 $this->config->setCheckboxSvg(
'checkbox.svg');
195 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --checkbox-svg 'checkbox.svg' --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
196 $this->assertSame($exp, $this->config->getCommandLineConfig());
201 $this->config->setCheckboxCheckedSvg(
'checkbox_checked.svg');
202 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --checkbox-checked-svg 'checkbox_checked.svg' --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
203 $this->assertSame($exp, $this->config->getCommandLineConfig());
208 $this->config->setRadioButtonSvg(
'radiobutton.svg');
209 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --radiobutton-svg 'radiobutton.svg' --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
210 $this->assertSame($exp, $this->config->getCommandLineConfig());
215 $this->config->setRadioButtonCheckedSvg(
'radiobutton_checked.svg');
216 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --radiobutton-checked-svg 'radiobutton_checked.svg' --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
217 $this->assertSame($exp, $this->config->getCommandLineConfig());
222 $this->config->setExternalLinks(
false);
223 $exp =
" --zoom 1 --disable-external-links --disable-forms --orientation Portrait --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
224 $this->assertSame($exp, $this->config->getCommandLineConfig());
229 $this->config->setOrientation(
'Landscape');
230 $exp =
" --zoom 1 --enable-external-links --disable-forms --orientation Landscape --page-size 'A4' --javascript-delay 500 --margin-bottom '0.5cm' --margin-left '0.5cm' --margin-right '2cm' --margin-top '2cm' --quiet " . self::COOKIE_STRING;
231 $this->assertSame($exp, $this->config->getCommandLineConfig());
236 $this->assertTrue($this->config::supportMultiSourcesFiles());
241 $this->assertSame([], $this->config->getConfig());
246 $this->config->setExternalLinks(
false);
247 $this->config->setEnabledForms(
true);
249 $this->assertTrue($cfg->getEnabledForms());
250 $this->assertFalse($cfg->getExternalLinks());
257 "enable_forms" =>
"true",
258 "external_links" =>
"true",
259 "user_stylesheet" =>
"my_style_sheet.css",
260 "low_quality" =>
"0",
262 "orientation" =>
"Landscape",
264 "margin_left" =>
"1cm",
265 "margin_right" =>
'2cm',
266 "footer_html_spacing" => 3,
267 "footer_html" =>
"<div>my html </div>",
268 "footer_text_line" =>
"1",
269 "footer_text_center" =>
"my footer text",
270 "footer_text_spacing" => 1,
271 "footer_text_right" =>
"right text",
272 "footer_text_left" =>
"left text",
273 "footer_select" =>
"0",
274 "head_html_spacing" =>
"1",
275 "head_html_line" =>
"0",
276 "head_text_line" =>
"1",
277 "head_text_spacing" =>
"1",
278 "head_text_right" =>
"head text right",
279 "head_text_center" =>
"head text center",
280 "head_text_left" =>
"head text left",
281 "header_select" =>
"1",
282 "radio_button_checked_svg" =>
"r_c.svg",
283 "radio_button_svg" =>
"r.svg",
284 "checkbox_checked_svg" =>
"c_c.svg",
285 "checkbox_svg" =>
"c.svg",
286 "javascript_delay" =>
"231",
287 "print_media_type" =>
"1",
288 "margin_top" =>
"5cm",
289 "margin_bottom" =>
"6cm",
292 $this->assertSame(1, $cfg->getHeaderHtmlSpacing());
293 $this->assertFalse($cfg->isHeaderHtmlLine());
294 $this->assertTrue($cfg->isHeaderTextLine());
295 $this->assertSame(1, $cfg->getHeaderTextSpacing());
296 $this->assertSame(
"head text right", $cfg->getHeaderTextRight());
297 $this->assertSame(
"head text center", $cfg->getHeaderTextCenter());
298 $this->assertSame(
"head text left", $cfg->getHeaderTextLeft());
299 $this->assertSame(1, $cfg->getHeaderType());
300 $this->assertSame(
"r_c.svg", $cfg->getRadioButtonCheckedSvg());
301 $this->assertSame(
"r.svg", $cfg->getRadioButtonSvg());
302 $this->assertSame(
"c_c.svg", $cfg->getCheckboxCheckedSvg());
303 $this->assertSame(
"c.svg", $cfg->getCheckboxSvg());
304 $this->assertSame(231, $cfg->getJavascriptDelay());
305 $this->assertTrue($cfg->getPrintMediaType());
306 $this->assertSame(
'5cm', $cfg->getMarginTop());
307 $this->assertSame(
'6cm', $cfg->getMarginBottom());
308 $this->assertSame(0.4, $cfg->getZoom());
309 $this->assertTrue($cfg->getExternalLinks());
310 $this->assertFalse($cfg->getLowQuality());
311 $this->assertFalse($cfg->getGreyscale());
312 $this->assertSame(
'Landscape', $cfg->getOrientation());
313 $this->assertSame(
'A1', $cfg->getPageSize());
314 $this->assertSame(
'1cm', $cfg->getMarginLeft());
315 $this->assertSame(
'2cm', $cfg->getMarginRight());
316 $this->assertSame(3, $cfg->getFooterHtmlSpacing());
317 $this->assertSame(
'<div>my html </div>', $cfg->getFooterHtml());
318 $this->assertSame(
'my footer text', $cfg->getFooterTextCenter());
319 $this->assertTrue($cfg->isFooterTextLine());
320 $this->assertSame(1, $cfg->getFooterTextSpacing());
321 $this->assertSame(
'right text', $cfg->getFooterTextRight());
322 $this->assertSame(
'left text', $cfg->getFooterTextLeft());
323 $this->assertSame(0, $cfg->getFooterType());
testGetCommandLineConfigWithEnabledPrintMediaType()
string $default_margin_args
testInstanceCanBeCreated()
testSupportMultiSourceFiles()
testGetCommandLineConfigSimple()
testDefaultConfigCommandline()
testGetCommandLineConfigWithFooterTextWithoutLine()
testGetCommandLineConfigOnObject()
testGetCommandLineConfigWithCheckedCheckbox()
testGetCommandLineConfigWithRadiobutton()
testGetCommandLineConfigWithLandscape()
testGetCommandLineConfigWithHeaderTextWithoutLine()
testGetConfigShouldReturnConfigObject()
testGetCommandLineConfigWithCheckbox()
testGetCommandLineConfigWithEnabledLowQuality()
testGetCommandLineConfigWithHeaderHtmlWithHeaderTextConfigured()
ilWkhtmlToPdfConfig $config
testGetCommandLineConfigWithDisabledExternalLinks()
testGetCommandLineConfigWithFooterHtmlWithLine()
testGetCommandLineConfigWithEnabledExternalLinks()
testGetCommandLineConfigWithHeaderHtmlWithoutLine()
testGetCommandLineConfigWithEnabledForms()
testGetCommandLineConfigWithCheckedRadiobutton()
testReadConfigFromObject()
testGetCommandLineConfigWithFooterHtmlWithoutLine()
testGetCommandLineConfigWithGrayscale()