diff --git a/lib/SP/Domain/Account/Services/AccountFileService.php b/lib/SP/Domain/Account/Services/AccountFileService.php index 8bfb8cec..a1bb5e6b 100644 --- a/lib/SP/Domain/Account/Services/AccountFileService.php +++ b/lib/SP/Domain/Account/Services/AccountFileService.php @@ -48,17 +48,12 @@ use function SP\__u; */ final class AccountFileService extends Service implements AccountFileServiceInterface { - private AccountFileRepositoryInterface $accountFileRepository; - private ImageUtilInterface $imageUtil; public function __construct( Application $application, - AccountFileRepositoryInterface $accountFileRepository, - ImageUtilInterface $imageUtil + private AccountFileRepositoryInterface $accountFileRepository, + private ImageUtilInterface $imageUtil ) { - $this->accountFileRepository = $accountFileRepository; - $this->imageUtil = $imageUtil; - parent::__construct($application); } diff --git a/tests/SP/Domain/Account/Services/AccountFileServiceTest.php b/tests/SP/Domain/Account/Services/AccountFileServiceTest.php index dd59874d..b3c2718f 100644 --- a/tests/SP/Domain/Account/Services/AccountFileServiceTest.php +++ b/tests/SP/Domain/Account/Services/AccountFileServiceTest.php @@ -64,6 +64,27 @@ class AccountFileServiceTest extends UnitaryTestCase $this->accountFileService->create($fileData); } + /** + * @throws \SP\Core\Exceptions\InvalidImageException + * @throws \SP\Core\Exceptions\QueryException + * @throws \SP\Core\Exceptions\ConstraintException + */ + public function testCreateWithThumbnail(): void + { + $fileData = FileData::buildFromSimpleModel(FileDataGenerator::factory()->buildFileData()); + $fileData->type = 'image/jpeg'; + + $this->accountFileRepository + ->expects(self::once()) + ->method('create') + ->with($fileData); + $this->imageUtil + ->expects(self::once()) + ->method('createThumbnail'); + + $this->accountFileService->create($fileData); + } + public function testGetById(): void { $fileData = FileExtData::buildFromSimpleModel(FileDataGenerator::factory()->buildFileExtData());