X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/bfbccbede14853c68edecf5dd5d08a50a6ed5c9d..refs/pull/3598/head:/tests/Uploads/AttachmentTest.php diff --git a/tests/Uploads/AttachmentTest.php b/tests/Uploads/AttachmentTest.php index 1682577bf..27a23bcae 100644 --- a/tests/Uploads/AttachmentTest.php +++ b/tests/Uploads/AttachmentTest.php @@ -9,7 +9,6 @@ use BookStack\Uploads\Attachment; use BookStack\Uploads\AttachmentService; use Illuminate\Http\UploadedFile; use Tests\TestCase; -use Tests\TestResponse; class AttachmentTest extends TestCase { @@ -18,13 +17,13 @@ class AttachmentTest extends TestCase */ protected function getTestFile(string $fileName): UploadedFile { - return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', 55, null, true); + return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', null, true); } /** * Uploads a file with the given name. */ - protected function uploadFile(string $name, int $uploadedTo = 0): \Illuminate\Foundation\Testing\TestResponse + protected function uploadFile(string $name, int $uploadedTo = 0): \Illuminate\Testing\TestResponse { $file = $this->getTestFile($name); @@ -56,6 +55,7 @@ class AttachmentTest extends TestCase $upload = new UploadedFile($filePath, $filename, $mimeType, null, true); $this->call('POST', '/attachments/upload', ['uploaded_to' => $page->id], [], ['file' => $upload], []); + return $page->attachments()->latest()->firstOrFail(); } @@ -128,7 +128,8 @@ class AttachmentTest extends TestCase $pageGet->assertSee($attachment->getUrl()); $attachmentGet = $this->get($attachment->getUrl()); - $attachmentGet->assertSee('Hi, This is a test file for testing the upload process.'); + $content = $attachmentGet->streamedContent(); + $this->assertStringContainsString('Hi, This is a test file for testing the upload process.', $content); $this->deleteUploads(); } @@ -340,5 +341,4 @@ class AttachmentTest extends TestCase $this->deleteUploads(); } - }