chore(tests): UT for ItemPreset

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-03-09 12:48:40 +01:00
parent 1b4de778ab
commit 2e4eca1c75
107 changed files with 1577 additions and 945 deletions

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,7 +29,7 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\DataModel\FileData;
use SP\DataModel\FileItemWithIdAndName;
use SP\Domain\Account\Ports\AccountFileService;
use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Exceptions\SPException;
@@ -92,7 +92,7 @@ final class UploadController extends ControllerBase
try {
$fileHandler = new FileHandler($file['tmp_name']);
$fileData = new FileData();
$fileData = new FileItemWithIdAndName();
$fileData->setAccountId($accountId);
$fileData->setName(htmlspecialchars($file['name'], ENT_QUOTES));
$fileData->setSize($file['size']);
@@ -161,14 +161,14 @@ final class UploadController extends ControllerBase
}
/**
* @param FileData $fileData
* @param FileItemWithIdAndName $fileData
* @param FileHandlerInterface $fileHandler
*
* @return string
* @throws SPException
* @throws FileException
*/
private function checkAllowedMimeType(FileData $fileData, FileHandlerInterface $fileHandler): string
private function checkAllowedMimeType(FileItemWithIdAndName $fileData, FileHandlerInterface $fileHandler): string
{
if (in_array($fileData->getType(), $this->configData->getFilesAllowedMime(), true)) {
return $fileData->getType();