]> BookStack Code Mirror - bookstack/blobdiff - tests/Exports/PdfExportTest.php
Perms: Fixed some issues made when adding transactions
[bookstack] / tests / Exports / PdfExportTest.php
index 9d85c69e23a0b8ede1c62cecb2cd8c4b49f41db6..e4de87d0d2fdb55f26b1da4ef88416ff2aa4b811 100644 (file)
@@ -5,6 +5,7 @@ namespace Tests\Exports;
 use BookStack\Entities\Models\Page;
 use BookStack\Exceptions\PdfExportException;
 use BookStack\Exports\PdfGenerator;
+use FilesystemIterator;
 use Tests\TestCase;
 
 class PdfExportTest extends TestCase
@@ -128,7 +129,7 @@ class PdfExportTest extends TestCase
         }, PdfExportException::class);
     }
 
-    public function test_pdf_command_timout_option_limits_export_time()
+    public function test_pdf_command_timeout_option_limits_export_time()
     {
         $page = $this->entities->page();
         $command = 'php -r \'sleep(4);\'';
@@ -143,4 +144,19 @@ class PdfExportTest extends TestCase
         }, PdfExportException::class,
             "PDF Export via command failed due to timeout at 1 second(s)");
     }
+
+    public function test_pdf_command_option_does_not_leave_temp_files()
+    {
+        $tempDir = sys_get_temp_dir();
+        $startTempFileCount = iterator_count((new FileSystemIterator($tempDir, FilesystemIterator::SKIP_DOTS)));
+
+        $page = $this->entities->page();
+        $command = 'cp {input_html_path} {output_pdf_path}';
+        config()->set('exports.pdf_command', $command);
+
+        $this->asEditor()->get($page->getUrl('/export/pdf'));
+
+        $afterTempFileCount = iterator_count((new FileSystemIterator($tempDir, FilesystemIterator::SKIP_DOTS)));
+        $this->assertEquals($startTempFileCount, $afterTempFileCount);
+    }
 }