5
5
use BookStack \Entities \Models \Page ;
6
6
use BookStack \Exceptions \PdfExportException ;
7
7
use BookStack \Exports \PdfGenerator ;
8
+ use FilesystemIterator ;
8
9
use Tests \TestCase ;
9
10
10
11
class PdfExportTest extends TestCase
@@ -128,7 +129,7 @@ public function test_pdf_command_option_errors_if_command_returns_error_status()
128
129
}, PdfExportException::class);
129
130
}
130
131
131
- public function test_pdf_command_timout_option_limits_export_time ()
132
+ public function test_pdf_command_timeout_option_limits_export_time ()
132
133
{
133
134
$ page = $ this ->entities ->page ();
134
135
$ command = 'php -r \'sleep(4); \'' ;
@@ -143,4 +144,19 @@ public function test_pdf_command_timout_option_limits_export_time()
143
144
}, PdfExportException::class,
144
145
"PDF Export via command failed due to timeout at 1 second(s) " );
145
146
}
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
+ }
146
162
}
0 commit comments