test(IT): Test account copy

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-08-05 08:21:24 +02:00
parent a01693a9b4
commit 1fb90bcd26
8 changed files with 170 additions and 42 deletions

View File

@@ -30,6 +30,7 @@ use SP\Domain\Account\Ports\AccountService;
use SP\Domain\CustomField\Ports\CustomFieldDataService;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\AccountForm;
use SP\Modules\Web\Forms\FormInterface;
use SP\Mvc\Controller\ItemTrait;
use SP\Mvc\Controller\WebControllerHelper;
@@ -41,7 +42,7 @@ abstract class AccountSaveBase extends AccountControllerBase
use ItemTrait;
use JsonTrait;
protected readonly AccountForm $accountForm;
protected readonly FormInterface $accountForm;
public function __construct(
Application $application,

View File

@@ -25,22 +25,24 @@
namespace SP\Modules\Web\Controllers\Account;
use Exception;
use JsonException;
use SP\Core\Acl\Acl;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Core\Exceptions\ValidationException;
use SP\Domain\Http\Dtos\JsonMessage;
use function SP\__u;
use function SP\processException;
/**
* Class SaveCopyController
*/
final class SaveCopyController extends AccountSaveBase
{
/**
* @return bool
* @throws JsonException
* @return bool|null
* @throws SPException
*/
public function saveCopyAction(): ?bool
{
@@ -49,15 +51,16 @@ final class SaveCopyController extends AccountSaveBase
$accountId = $this->accountService->create($this->accountForm->getItemData());
$accountDetails = $this->accountService->getByIdEnriched($accountId)->getAccountVData();
$accountDetails = $this->accountService->getByIdEnriched($accountId);
$this->eventDispatcher->notify(
'create.account',
new Event(
$this, EventMessage::factory()
->addDescription(__u('Account created'))
->addDetail(__u('Account'), $accountDetails->getName())
->addDetail(__u('Client'), $accountDetails->getClientName())
$this,
EventMessage::factory()
->addDescription(__u('Account created'))
->addDetail(__u('Account'), $accountDetails->getName())
->addDetail(__u('Client'), $accountDetails->getClientName())
)
);
@@ -70,8 +73,8 @@ final class SaveCopyController extends AccountSaveBase
return $this->returnJsonResponseData(
[
'itemId' => $accountId,
'nextAction' => Acl::getActionRoute(AclActionsInterface::ACCOUNT_EDIT),
'itemId' => $accountId,
'nextAction' => $this->acl->getRouteFor(AclActionsInterface::ACCOUNT_EDIT),
],
JsonMessage::JSON_SUCCESS,
__u('Account created')