]> BookStack Code Mirror - bookstack/blobdiff - tests/Uploads/AttachmentTest.php
Applied StyleCI changes, added php/larastan to attribution
[bookstack] / tests / Uploads / AttachmentTest.php
index 26f092bcc3b5c0039f823ff0d43c4457e0c8de3d..5545edf13255d1bf1df24e8c7e4e370b0f21f545 100644 (file)
@@ -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();
     }
 
@@ -109,7 +109,8 @@ class AttachmentTest extends TestCase
 
         $attachment = Attachment::query()->orderBy('id', 'desc')->first();
         $this->assertStringNotContainsString($fileName, $attachment->path);
-        $this->assertStringEndsWith('.txt', $attachment->path);
+        $this->assertStringEndsWith('-txt', $attachment->path);
+        $this->deleteUploads();
     }
 
     public function test_file_display_and_access()
@@ -339,5 +340,4 @@ class AttachmentTest extends TestCase
 
         $this->deleteUploads();
     }
-
 }