chore: Create tests for AccountFileService

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2022-11-27 19:55:03 +01:00
parent bd8e599014
commit 5531af39f4
2 changed files with 23 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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());