File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,11 @@ public function toString()
215
215
*/
216
216
public function setOptions ($ options = array ())
217
217
{
218
+ // #264 tmpDir must be set before calling processOptions
219
+ if (isset ($ options ['tmpDir ' ])) {
220
+ $ this ->tmpDir = $ options ['tmpDir ' ];
221
+ unset($ options ['tmpDir ' ]);
222
+ }
218
223
$ options = $ this ->processOptions ($ options );
219
224
foreach ($ options as $ key => $ val ) {
220
225
if (is_int ($ key )) {
Original file line number Diff line number Diff line change @@ -255,9 +255,13 @@ public function testCanPassGlobalOptionsInConstructor()
255
255
$ inFile = $ this ->getHtmlAsset ();
256
256
$ outFile = $ this ->getOutFile ();
257
257
$ binary = $ this ->getBinary ();
258
+ $ tmpDir = realpath (sys_get_temp_dir ()) . DIRECTORY_SEPARATOR . uniqid ();
259
+ mkdir ($ tmpDir );
258
260
259
261
$ pdf = new Pdf (array (
260
262
'binary ' => $ binary ,
263
+ 'tmpDir ' => $ tmpDir ,
264
+ 'header-html ' => '<p>header</p> ' ,
261
265
'no-outline ' ,
262
266
'margin-top ' => 0 ,
263
267
'allow ' => array (
@@ -266,11 +270,11 @@ public function testCanPassGlobalOptionsInConstructor()
266
270
),
267
271
));
268
272
$ this ->assertInstanceOf ('mikehaertl\wkhtmlto\Pdf ' , $ pdf ->addPage ($ inFile ));
273
+ $ this ->assertEquals ($ tmpDir , $ pdf ->tmpDir );
269
274
$ this ->assertTrue ($ pdf ->saveAs ($ outFile ));
270
275
271
- $ tmpFile = $ pdf ->getPdfFilename ();
272
276
$ this ->assertFileExists ($ outFile );
273
- $ this ->assertEquals ( " $ binary --no-outline --margin-top '0' --allow '/tmp' --allow '/test' ' $ inFile' ' $ tmpFile ' " , (string ) $ pdf ->getCommand ());
277
+ $ this ->assertRegExp ( " # $ binary --header-html ' $ tmpDir /tmp_wkhtmlto_pdf_[^ ]+\.html' -- no-outline --margin-top '0' --allow '/tmp' --allow '/test' '$ inFile' ' $ tmpDir /tmp_wkhtmlto_pdf_[^ ]+\.pdf'# " , (string ) $ pdf ->getCommand ());
274
278
unlink ($ outFile );
275
279
}
276
280
public function testCanSetGlobalOptions ()
@@ -402,7 +406,6 @@ public function testCanUseXvfbRun()
402
406
}
403
407
404
408
405
-
406
409
protected function getBinary ()
407
410
{
408
411
return '/usr/local/bin/wkhtmltopdf ' ;
You can’t perform that action at this time.
0 commit comments