55use BookStack \Entities \Models \Page ;
66use BookStack \Exceptions \PdfExportException ;
77use BookStack \Exports \PdfGenerator ;
8+ use FilesystemIterator ;
89use Tests \TestCase ;
910
1011class PdfExportTest extends TestCase
@@ -128,7 +129,7 @@ public function test_pdf_command_option_errors_if_command_returns_error_status()
128129 }, PdfExportException::class);
129130 }
130131
131- public function test_pdf_command_timout_option_limits_export_time ()
132+ public function test_pdf_command_timeout_option_limits_export_time ()
132133 {
133134 $ page = $ this ->entities ->page ();
134135 $ command = 'php -r \'sleep(4); \'' ;
@@ -143,4 +144,19 @@ public function test_pdf_command_timout_option_limits_export_time()
143144 }, PdfExportException::class,
144145 "PDF Export via command failed due to timeout at 1 second(s) " );
145146 }
147+
148+ public function test_pdf_command_option_does_not_leave_temp_files ()
149+ {
150+ $ tempDir = sys_get_temp_dir ();
151+ $ startTempFileCount = iterator_count ((new FileSystemIterator ($ tempDir , FilesystemIterator::SKIP_DOTS )));
152+
153+ $ page = $ this ->entities ->page ();
154+ $ command = 'cp {input_html_path} {output_pdf_path} ' ;
155+ config ()->set ('exports.pdf_command ' , $ command );
156+
157+ $ this ->asEditor ()->get ($ page ->getUrl ('/export/pdf ' ));
158+
159+ $ afterTempFileCount = iterator_count ((new FileSystemIterator ($ tempDir , FilesystemIterator::SKIP_DOTS )));
160+ $ this ->assertEquals ($ startTempFileCount , $ afterTempFileCount );
161+ }
146162}
0 commit comments