Skip to content

Commit 5647872

Browse files
Add test + Fix comment
1 parent 690390a commit 5647872

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private function resolveThumbnailPath(?int $width = null, ?int $height = null):
265265

266266
public function __toString()
267267
{
268-
// If thumbnail is used in a blade template without parameters, we want to return the URL directly
268+
// Return URL when Thumbnail is used as a string
269269
return $this->make();
270270
}
271271
}

tests/Unit/Form/Eloquent/Uploads/SharpUploadModelTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Code16\Sharp\Form\Eloquent\Uploads\SharpUploadModel;
4+
use Code16\Sharp\Form\Eloquent\Uploads\Thumbnails\Thumbnail;
45
use Code16\Sharp\Tests\Fixtures\Person;
56
use Illuminate\Support\Facades\Storage;
67

@@ -43,6 +44,16 @@
4344
->toBeTrue();
4445
});
4546

47+
it('allows to display thumbnails with no width or height params', function () {
48+
$file = createImage();
49+
$upload = createSharpUploadModel($file);
50+
51+
expect($upload->thumbnail())
52+
->toBeInstanceOf(Thumbnail::class)
53+
->and($upload->thumbnail()->__toString())
54+
->toStartWith('/storage/thumbnails/data/-_q-90/'.basename($file));
55+
});
56+
4657
it('returns null on error with a thumbnail creation', function () {
4758
$file = createImage();
4859
$upload = createSharpUploadModel($file);

0 commit comments

Comments
 (0)