]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/ExportTest.php
ZIP Exports: Finished up format doc, move files, started builder
[bookstack] / tests / Entity / ExportTest.php
index 040f69013a5f1bee44b48759f10a13f644410c36..11cfddb206ebf9a9276ffffda61e58b3b6b103a2 100644 (file)
@@ -5,8 +5,8 @@ namespace Tests\Entity;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
-use BookStack\Entities\Tools\PdfGenerator;
 use BookStack\Exceptions\PdfExportException;
+use BookStack\Exports\PdfGenerator;
 use Illuminate\Support\Facades\Storage;
 use Tests\TestCase;
 
@@ -529,6 +529,22 @@ class ExportTest extends TestCase
         }, PdfExportException::class);
     }
 
+    public function test_pdf_command_timout_option_limits_export_time()
+    {
+        $page = $this->entities->page();
+        $command = 'php -r \'sleep(4);\'';
+        config()->set('exports.pdf_command', $command);
+        config()->set('exports.pdf_command_timeout', 1);
+
+        $this->assertThrows(function () use ($page) {
+            $start = time();
+            $this->withoutExceptionHandling()->asEditor()->get($page->getUrl('/export/pdf'));
+
+            $this->assertTrue(time() < ($start + 3));
+        }, PdfExportException::class,
+            "PDF Export via command failed due to timeout at 1 second(s)");
+    }
+
     public function test_html_exports_contain_csp_meta_tag()
     {
         $entities = [