@@ -75,6 +75,99 @@ public function testGetCommand()
7575 $ result = $ method ->invokeArgs ($ Pdf ->engine (), []);
7676 $ expected = "wkhtmltopdf --quiet --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'UTF-8' --boolean --string 'value' --integer '42' --array 'first' 'firstValue' --array 'second' 'secondValue' - - " ;
7777 $ this ->assertEquals ($ expected , $ result );
78+
79+ $ Pdf = new CakePdf ([
80+ 'engine ' => [
81+ 'className ' => 'CakePdf.WkHtmlToPdf ' ,
82+ 'options ' => [
83+ 'cover ' => 'cover.html ' ,
84+ 'toc ' => true ,
85+ ],
86+ ],
87+ ]);
88+ $ result = $ method ->invokeArgs ($ Pdf ->engine (), []);
89+ $ expected = "wkhtmltopdf --quiet --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'UTF-8' cover 'cover.html' toc - - " ;
90+ $ this ->assertEquals ($ expected , $ result );
91+
92+ $ Pdf = new CakePdf ([
93+ 'engine ' => [
94+ 'className ' => 'CakePdf.WkHtmlToPdf ' ,
95+ 'options ' => [
96+ 'encoding ' => 'UTF-16 ' ,
97+ 'title ' => 'Test ' ,
98+ 'cover ' => 'cover.html ' ,
99+ 'toc ' => [
100+ 'zoom ' => 5 ,
101+ 'encoding ' => 'ISO-8859-1 ' ,
102+ ],
103+ ],
104+ ],
105+ ]);
106+ $ result = $ method ->invokeArgs ($ Pdf ->engine (), []);
107+ $ expected = "wkhtmltopdf --quiet --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'UTF-16' --title 'Test' cover 'cover.html' toc --zoom '5' --encoding 'ISO-8859-1' - - " ;
108+ $ this ->assertEquals ($ expected , $ result );
109+
110+ $ Pdf = new CakePdf ([
111+ 'engine ' => [
112+ 'className ' => 'CakePdf.WkHtmlToPdf ' ,
113+ 'options ' => [
114+ 'cover ' => [
115+ 'url ' => 'cover.html ' ,
116+ 'enable-smart-shrinking ' => true ,
117+ 'zoom ' => 10 ,
118+ ],
119+ 'toc ' => true ,
120+ ],
121+ ],
122+ ]);
123+ $ result = $ method ->invokeArgs ($ Pdf ->engine (), []);
124+ $ expected = "wkhtmltopdf --quiet --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'UTF-8' cover 'cover.html' --enable-smart-shrinking --zoom '10' toc - - " ;
125+ $ this ->assertEquals ($ expected , $ result );
126+
127+ $ Pdf = new CakePdf ([
128+ 'engine ' => [
129+ 'className ' => 'CakePdf.WkHtmlToPdf ' ,
130+ 'options ' => [
131+ 'zoom ' => 4 ,
132+ 'cover ' => [
133+ 'url ' => 'cover.html ' ,
134+ 'enable-smart-shrinking ' => true ,
135+ 'zoom ' => 10 ,
136+ ],
137+ 'toc ' => [
138+ 'disable-dotted-lines ' => true ,
139+ 'xsl-style-sheet ' => 'style.xsl ' ,
140+ 'zoom ' => 5 ,
141+ 'encoding ' => 'ISO-8859-1 ' ,
142+ ],
143+ ],
144+ ],
145+ ]);
146+ $ result = $ method ->invokeArgs ($ Pdf ->engine (), []);
147+ $ expected = "wkhtmltopdf --quiet --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'UTF-8' --zoom '4' cover 'cover.html' --enable-smart-shrinking --zoom '10' toc --disable-dotted-lines --xsl-style-sheet 'style.xsl' --zoom '5' --encoding 'ISO-8859-1' - - " ;
148+ $ this ->assertEquals ($ expected , $ result );
149+ }
150+
151+ public function testCoverUrlMissing ()
152+ {
153+ $ this ->expectException (Exception::class);
154+ $ this ->expectExceptionMessage ('The url for the cover is missing. Use the "url" index. ' );
155+
156+ $ class = new \ReflectionClass (WkHtmlToPdfEngine::class);
157+ $ method = $ class ->getMethod ('_getCommand ' );
158+ $ method ->setAccessible (true );
159+ $ Pdf = new CakePdf ([
160+ 'engine ' => [
161+ 'className ' => 'CakePdf.WkHtmlToPdf ' ,
162+ 'options ' => [
163+ 'cover ' => [
164+ 'enable-smart-shrinking ' => true ,
165+ 'zoom ' => 10 ,
166+ ],
167+ ],
168+ ],
169+ ]);
170+ $ method ->invokeArgs ($ Pdf ->engine (), []);
78171 }
79172
80173 public function testGetBinaryPath ()
0 commit comments