Updated cover image methods so image parameter is not optional but still nullable

This commit is contained in:
Dan Brown 2020-02-15 18:38:36 +00:00
parent 98ab3c1ffb
commit 5978d9a0d3
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
4 changed files with 4 additions and 4 deletions

View File

@ -76,7 +76,7 @@ class BaseRepo
* @throws ImageUploadException
* @throws \Exception
*/
public function updateCoverImage(HasCoverImage $entity, UploadedFile $coverImage = null, bool $removeImage = false)
public function updateCoverImage(HasCoverImage $entity, ?UploadedFile $coverImage, bool $removeImage = false)
{
if ($coverImage) {
$this->imageRepo->destroyImage($entity->cover);

View File

@ -108,7 +108,7 @@ class BookRepo
* @throws ImageUploadException
* @throws Exception
*/
public function updateCoverImage(Book $book, UploadedFile $coverImage = null, bool $removeImage = false)
public function updateCoverImage(Book $book, ?UploadedFile $coverImage, bool $removeImage = false)
{
$this->baseRepo->updateCoverImage($book, $coverImage, $removeImage);
}

View File

@ -123,7 +123,7 @@ class BookshelfRepo
* @throws ImageUploadException
* @throws Exception
*/
public function updateCoverImage(Bookshelf $shelf, UploadedFile $coverImage = null, bool $removeImage = false)
public function updateCoverImage(Bookshelf $shelf, ?UploadedFile $coverImage, bool $removeImage = false)
{
$this->baseRepo->updateCoverImage($shelf, $coverImage, $removeImage);
}

View File

@ -100,7 +100,7 @@ class BookShelfTest extends TestCase
$lastImage = Image::query()->orderByDesc('id')->firstOrFail();
$shelf = Bookshelf::query()->where('name', '=', $shelfInfo['name'])->first();
$this->assertDatabaseHas('bookshelves', [
'id' => $shelf,
'id' => $shelf->id,
'image_id' => $lastImage->id,
]);
$this->assertEquals($lastImage->id, $shelf->cover->id);