test(DI): Implement definitions test

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-06-07 14:31:08 +02:00
parent 2ee21ac01a
commit a6dad3341f
60 changed files with 1015 additions and 902 deletions

View File

@@ -34,8 +34,8 @@ use SP\Domain\Api\Ports\ApiService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Acl\AclInterface;
use SP\Domain\Core\Exceptions\InvalidClassException;
use SP\Domain\Export\Dtos\BackupFiles;
use SP\Domain\Export\Ports\BackupFileService;
use SP\Domain\Export\Services\BackupFileHelper;
use SP\Modules\Api\Controllers\ControllerBase;
use SP\Modules\Api\Controllers\Help\ConfigHelp;
@@ -46,22 +46,19 @@ use SP\Modules\Api\Controllers\Help\ConfigHelp;
*/
final class BackupController extends ControllerBase
{
private BackupFileService $fileBackupService;
/**
* @throws InvalidClassException
*/
public function __construct(
Application $application,
Klein $router,
ApiService $apiService,
AclInterface $acl,
BackupFileService $fileBackupService
Application $application,
Klein $router,
ApiService $apiService,
AclInterface $acl,
private readonly BackupFileService $fileBackupService,
private readonly BackupFiles $backupFiles
) {
parent::__construct($application, $router, $apiService, $acl);
$this->fileBackupService = $fileBackupService;
$this->apiService->setHelpClass(ConfigHelp::class);
}
@@ -98,24 +95,18 @@ final class BackupController extends ControllerBase
}
/**
* @param string|null $path
* @param string|null $path
*
* @return array[]
*/
private function buildBackupFiles(?string $path): array
{
$backupFiles = $this->backupFiles->withPath($path);
return [
'files' => [
'app' => BackupFileHelper::getAppBackupFilename(
$path,
$this->fileBackupService->getHash(),
true
),
'db' => BackupFileHelper::getDbBackupFilename(
$path,
$this->fileBackupService->getHash(),
true
),
'app' => (string)$backupFiles->getAppBackupFile(),
'db' => (string)$backupFiles->getDbBackupFile(),
],
];
}