From b36455ff46d305ca8b95f6f934f197dc746c0282 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Mon, 13 Sep 2021 01:18:40 +0200 Subject: [PATCH] Add slash test --- tests/ResizerTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/ResizerTest.php b/tests/ResizerTest.php index 4b4430c..327fa2c 100644 --- a/tests/ResizerTest.php +++ b/tests/ResizerTest.php @@ -48,6 +48,22 @@ class ResizerTest extends TestCase $this->assertHasFile('pages/test-500x600.jpg'); } + public function testCopyOriginalFileWithoutSizesWhenFilenameDoesntBeginWithASlash(): void + { + Setting::set('folders', [['folder' => '/pages']]); + Setting::set('sizes', []); + Setting::set('breakpoints', []); + + $file = UploadedFile::fake()->image('test.jpg', 500, 600); + $media = MediaLibrary::instance(); + $media->put('/pages/test.jpg', $file->get()); + Event::fire('media.file.upload', [null, 'pages/test.jpg', null]); + + $this->assertFileCount(2, 'pages'); + $this->assertHasFile('pages/test.jpg'); + $this->assertHasFile('pages/test-500x600.jpg'); + } + public function testCopyTwoDirectoriesDeepButNotAnotherDirectory(): void { Setting::set('folders', [['folder' => '/pages']]);