mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-07 23:03:00 +03:00
ZIP Exports: Improved temp file tracking & clean-up
This commit is contained in:
@@ -7,6 +7,7 @@ use BookStack\Entities\Repos\BookRepo;
|
||||
use BookStack\Entities\Tools\PageContent;
|
||||
use BookStack\Uploads\Attachment;
|
||||
use BookStack\Uploads\Image;
|
||||
use FilesystemIterator;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
use Tests\TestCase;
|
||||
@@ -60,6 +61,24 @@ class ZipExportTest extends TestCase
|
||||
$this->assertEquals($instanceId, $zipInstanceId);
|
||||
}
|
||||
|
||||
public function test_export_leaves_no_temp_files()
|
||||
{
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$startTempFileCount = iterator_count((new FileSystemIterator($tempDir, FilesystemIterator::SKIP_DOTS)));
|
||||
|
||||
$page = $this->entities->pageWithinChapter();
|
||||
$this->asEditor();
|
||||
$pageResp = $this->get($page->getUrl("/export/zip"));
|
||||
$pageResp->streamedContent();
|
||||
$pageResp->assertOk();
|
||||
$this->get($page->chapter->getUrl("/export/zip"))->assertOk();
|
||||
$this->get($page->book->getUrl("/export/zip"))->assertOk();
|
||||
|
||||
$afterTempFileCount = iterator_count((new FileSystemIterator($tempDir, FilesystemIterator::SKIP_DOTS)));
|
||||
|
||||
$this->assertEquals($startTempFileCount, $afterTempFileCount);
|
||||
}
|
||||
|
||||
public function test_page_export()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
|
Reference in New Issue
Block a user