From: Dan Brown Date: Sun, 22 May 2022 10:58:22 +0000 (+0100) Subject: Fixed issue caused by changing test method defaults X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/b69722c3b5aa0c64f46c97f4ba6e4532387e711b Fixed issue caused by changing test method defaults --- diff --git a/tests/Uploads/UsesImages.php b/tests/Uploads/UsesImages.php index 513a5d49e..3140d0cd2 100644 --- a/tests/Uploads/UsesImages.php +++ b/tests/Uploads/UsesImages.php @@ -40,9 +40,9 @@ trait UsesImages /** * Get a test image that can be uploaded. */ - protected function getTestImage(string $fileName, ?string $testDataFileName = null): UploadedFile + protected function getTestImage(string $fileName, ?string $testDataFileName = null, $mimeType = 'image/png'): UploadedFile { - return new UploadedFile($this->getTestImageFilePath($testDataFileName), $fileName, 'image/png', null, true); + return new UploadedFile($this->getTestImageFilePath($testDataFileName), $fileName, $mimeType, null, true); } /** @@ -74,7 +74,7 @@ trait UsesImages */ protected function uploadImage($name, $uploadedTo = 0, $contentType = 'image/png', ?string $testDataFileName = null) { - $file = $this->getTestImage($name, $testDataFileName); + $file = $this->getTestImage($name, $testDataFileName, $contentType); return $this->withHeader('Content-Type', $contentType) ->call('POST', '/images/gallery', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []); @@ -87,13 +87,13 @@ trait UsesImages * * @return array{name: string, path: string, page: Page, response: stdClass} */ - protected function uploadGalleryImage(Page $page = null, string $testDataFileName = 'first-image.png', string $contentType = 'image/png') + protected function uploadGalleryImage(Page $page = null, string $testDataFileName = null, string $contentType = 'image/png') { if ($page === null) { $page = Page::query()->first(); } - $imageName = $testDataFileName; + $imageName = $testDataFileName ?? 'first-image.png'; $relPath = $this->getTestImagePath('gallery', $imageName); $this->deleteImage($relPath);