* [ADD] Unit testing. Work in progress

* [ADD] Added verification after XML exporting
* [MOD] Updated EN translations
* [MOD] Code refactoring
This commit is contained in:
nuxsmin
2018-07-17 01:31:36 +02:00
parent 1f66ed0951
commit 833c93bb99
22 changed files with 3970 additions and 2698 deletions

View File

@@ -33,6 +33,7 @@ use SP\Http\JsonResponse;
use SP\Modules\Web\Controllers\Traits\ConfigTrait;
use SP\Services\Backup\FileBackupService;
use SP\Services\Export\XmlExportService;
use SP\Services\Export\XmlVerifyService;
/**
* Class ConfigBackupController
@@ -95,14 +96,36 @@ class ConfigBackupController extends SimpleControllerBase
SessionContext::close();
$this->dic->get(XmlExportService::class)
->doExport($exportPassword);
$export = $this->dic->get(XmlExportService::class);
$export->doExport(BACKUP_PATH, $exportPassword);
$this->eventDispatcher->notifyEvent('run.export.end',
new Event($this, EventMessage::factory()
->addDescription(__u('Proceso de exportación finalizado')))
);
$verify = $this->dic->get(XmlVerifyService::class);
if ($export->isEncrypted()) {
$verifyResult = $verify->verifyEncrypted($export->getExportFile(), $exportPassword);
} else {
$verifyResult = $verify->verify($export->getExportFile());
}
$nodes = $verifyResult->getNodes();
$this->eventDispatcher->notifyEvent('run.export.verify',
new Event($this, EventMessage::factory()
->addDescription(__u('Verificación de datos exportados finalizada'))
->addDetail(__u('Versión'), $verifyResult->getVersion())
->addDetail(__u('Encriptado'), $verifyResult->isEncrypted() ? __u('Sí') : __u('No'))
->addDetail(__u('Cuentas'), $nodes['Account'])
->addDetail(__u('Clientes'), $nodes['Client'])
->addDetail(__u('Categorías'), $nodes['Category'])
->addDetail(__u('Etiquetas'), $nodes['Tag'])
)
);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Proceso de exportación finalizado'));
} catch (\Exception $e) {
processException($e);