chore: Refactor Client naming

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-01-16 09:25:01 +01:00
parent c87f3abe39
commit 24fcc0abf4
19 changed files with 157 additions and 157 deletions

View File

@@ -29,7 +29,7 @@ use Klein\Klein;
use SP\Core\Application;
use SP\Domain\Api\Ports\ApiService;
use SP\Domain\Client\Ports\ClientAdapterInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Acl\AclInterface;
use SP\Domain\Core\Exceptions\InvalidClassException;
use SP\Modules\Api\Controllers\ControllerBase;
@@ -40,7 +40,7 @@ use SP\Modules\Api\Controllers\Help\ClientHelp;
*/
abstract class ClientBase extends ControllerBase
{
protected ClientServiceInterface $clientService;
protected ClientService $clientService;
protected ClientAdapterInterface $clientAdapter;
/**
@@ -49,9 +49,9 @@ abstract class ClientBase extends ControllerBase
public function __construct(
Application $application,
Klein $router,
ApiService $apiService,
AclInterface $acl,
ClientServiceInterface $clientService,
ApiService $apiService,
AclInterface $acl,
ClientService $clientService,
ClientAdapterInterface $clientAdapter
) {
parent::__construct($application, $router, $apiService, $acl);

View File

@@ -33,7 +33,7 @@ use SP\Domain\Account\Ports\AccountHistoryService;
use SP\Domain\Account\Ports\AccountSearchService;
use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Domain\Tag\Ports\TagServiceInterface;
@@ -62,19 +62,19 @@ final class BulkEditController extends ControllerBase
private AccountHistoryService $accountHistoryService;
private AccountGrid $accountGrid;
private CustomFieldServiceInterface $customFieldService;
private CategoryService $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
private CategoryService $categoryService;
private ClientService $clientService;
private TagServiceInterface $tagService;
private UserServiceInterface $userService;
private UserGroupServiceInterface $userGroupService;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
CategoryService $categoryService,
ClientServiceInterface $clientService,
TagServiceInterface $tagService,
UserServiceInterface $userService,
Application $application,
WebControllerHelper $webControllerHelper,
CategoryService $categoryService,
ClientService $clientService,
TagServiceInterface $tagService,
UserServiceInterface $userService,
UserGroupServiceInterface $userGroupService
) {
parent::__construct($application, $webControllerHelper);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers\Client;
use SP\Core\Application;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Modules\Web\Controllers\ControllerBase;
use SP\Modules\Web\Forms\ClientForm;
@@ -37,14 +37,14 @@ use SP\Mvc\Controller\WebControllerHelper;
*/
abstract class ClientSaveBase extends ControllerBase
{
protected \SP\Domain\Client\Ports\ClientServiceInterface $clientService;
protected CustomFieldServiceInterface $customFieldService;
protected ClientService $clientService;
protected CustomFieldServiceInterface $customFieldService;
protected ClientForm $form;
public function __construct(
Application $application,
Application $application,
WebControllerHelper $webControllerHelper,
ClientServiceInterface $clientService,
ClientService $clientService,
CustomFieldServiceInterface $customFieldService
) {
parent::__construct($application, $webControllerHelper);

View File

@@ -28,7 +28,7 @@ namespace SP\Modules\Web\Controllers\Client;
use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -47,13 +47,13 @@ abstract class ClientViewBase extends ControllerBase
{
use ItemTrait;
private ClientServiceInterface $clientService;
private ClientService $clientService;
private CustomFieldServiceInterface $customFieldService;
public function __construct(
Application $application,
Application $application,
WebControllerHelper $webControllerHelper,
ClientServiceInterface $clientService,
ClientService $clientService,
CustomFieldServiceInterface $customFieldService
) {
parent::__construct($application, $webControllerHelper);

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.
*
@@ -27,7 +27,7 @@ namespace SP\Modules\Web\Controllers\Client;
use JsonException;
use SP\Core\Application;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -48,14 +48,14 @@ final class SearchController extends ControllerBase
use ItemTrait;
use JsonTrait;
private ClientServiceInterface $clientService;
private ClientGrid $clientGrid;
private ClientService $clientService;
private ClientGrid $clientGrid;
public function __construct(
Application $application,
Application $application,
WebControllerHelper $webControllerHelper,
ClientServiceInterface $clientService,
ClientGrid $clientGrid
ClientService $clientService,
ClientGrid $clientGrid
) {
parent::__construct($application, $webControllerHelper);

View File

@@ -39,7 +39,7 @@ use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Account\Ports\PublicLinkService;
use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Acl\AccountPermissionException;
use SP\Domain\Core\Acl\AclActionsInterface;
@@ -79,8 +79,8 @@ final class AccountHelper extends AccountHelperBase
private ItemPresetServiceInterface $itemPresetService;
private MasterPassServiceInterface $masterPassService;
private AccountAclService $accountAclService;
private CategoryService $categoryService;
private ClientServiceInterface $clientService;
private CategoryService $categoryService;
private ClientService $clientService;
private CustomFieldServiceInterface $customFieldService;
private ?AccountPermission $accountAcl = null;
private ?int $accountId = null;
@@ -101,7 +101,7 @@ final class AccountHelper extends AccountHelperBase
AccountActionsHelper $accountActionsHelper,
AccountAclService $accountAclService,
CategoryService $categoryService,
ClientServiceInterface $clientService,
ClientService $clientService,
CustomFieldServiceInterface $customFieldService,
UserServiceInterface $userService,
UserGroupServiceInterface $userGroupService,

View File

@@ -33,7 +33,7 @@ use SP\Domain\Account\Ports\AccountHistoryService;
use SP\Domain\Account\Ports\AccountToUserGroupService;
use SP\Domain\Account\Ports\AccountToUserService;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Acl\AccountPermissionException;
use SP\Domain\Core\Acl\AclInterface;
@@ -68,7 +68,7 @@ final class AccountHistoryHelper extends AccountHelperBase
private AccountHistoryService $accountHistoryService,
private AccountAclService $accountAclService,
private CategoryService $categoryService,
private ClientServiceInterface $clientService,
private ClientService $clientService,
private AccountToUserService $accountToUserService,
private AccountToUserGroupService $accountToUserGroupService
) {

View File

@@ -35,7 +35,7 @@ use SP\Domain\Account\Dtos\AccountSearchFilterDto;
use SP\Domain\Account\Ports\AccountSearchConstants;
use SP\Domain\Account\Ports\AccountSearchService;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -68,21 +68,21 @@ final class AccountSearchHelper extends HelperBase
private int $queryTimeStart;
private bool $isIndex;
private ?AccountSearchFilterDto $accountSearchFilter = null;
private ClientServiceInterface $clientService;
private ClientService $clientService;
private AccountSearchService $accountSearchService;
private AccountActionsHelper $accountActionsHelper;
private CategoryService $categoryService;
private TagServiceInterface $tagService;
public function __construct(
Application $application,
TemplateInterface $template,
RequestInterface $request,
ClientServiceInterface $clientService,
CategoryService $categoryService,
TagServiceInterface $tagService,
AccountSearchService $accountSearchService,
AccountActionsHelper $accountActionsHelper
Application $application,
TemplateInterface $template,
RequestInterface $request,
ClientService $clientService,
CategoryService $categoryService,
TagServiceInterface $tagService,
AccountSearchService $accountSearchService,
AccountActionsHelper $accountActionsHelper
) {
parent::__construct($application, $template, $request);

View File

@@ -32,7 +32,7 @@ use SP\Domain\Account\Ports\AccountFileService;
use SP\Domain\Account\Ports\AccountHistoryService;
use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -64,7 +64,7 @@ final class IndexController extends ControllerBase
private TabsGridHelper $tabsGridHelper;
private CategoryService $categoryService;
private TagServiceInterface $tagService;
private ClientServiceInterface $clientService;
private ClientService $clientService;
private CustomFieldDefServiceInterface $customFieldDefService;
private AccountFileService $accountFileService;
private AccountService $accountService;
@@ -85,7 +85,7 @@ final class IndexController extends ControllerBase
Helpers\TabsGridHelper $tabsGridHelper,
CategoryService $categoryService,
TagServiceInterface $tagService,
ClientServiceInterface $clientService,
ClientService $clientService,
CustomFieldDefServiceInterface $customFieldDefService,
AccountFileService $accountFileService,
AccountService $accountService,

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.
*
@@ -25,7 +25,7 @@
namespace SP\Modules\Web\Controllers\Items;
use SP\Core\Application;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -39,12 +39,12 @@ use SP\Mvc\View\Components\SelectItemAdapter;
*/
final class ClientsController extends SimpleControllerBase
{
private ClientServiceInterface $clientService;
private ClientService $clientService;
public function __construct(
Application $application,
SimpleControllerHelper $simpleControllerHelper,
ClientServiceInterface $clientService
ClientService $clientService
) {
parent::__construct($application, $simpleControllerHelper);

View File

@@ -26,7 +26,7 @@ namespace SP\Domain\Client\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -37,32 +37,32 @@ use SP\Infrastructure\Database\QueryResult;
/**
* Class ClientRepository
*
* @template T of Client
* @template T of ClientModel
*/
interface ClientRepositoryInterface extends RepositoryInterface
interface ClientRepository extends RepositoryInterface
{
/**
* Creates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return QueryResult
* @throws DuplicatedItemException
* @throws SPException
*/
public function create(Client $client): QueryResult;
public function create(ClientModel $client): QueryResult;
/**
* Updates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return int
* @throws ConstraintException
* @throws QueryException
* @throws DuplicatedItemException
*/
public function update(Client $client): int;
public function update(ClientModel $client): int;
/**
* Returns the item for given id

View File

@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
/**
* Interface ClientServiceInterface
*/
interface ClientServiceInterface
interface ClientService
{
/**
* @throws ConstraintException
@@ -67,7 +67,7 @@ interface ClientServiceInterface
* @throws QueryException
* @throws NoSuchItemException
*/
public function delete(int $id): ClientServiceInterface;
public function delete(int $id): ClientService;
/**
* @param int[] $ids

View File

@@ -28,8 +28,8 @@ use SP\Core\Application;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientRepository;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
@@ -47,11 +47,11 @@ use function SP\__u;
*
* @template T of ClientModel
*/
final class Client extends Service implements ClientServiceInterface
final class Client extends Service implements ClientService
{
public function __construct(
Application $application,
private readonly ClientRepositoryInterface $clientRepository,
Application $application,
private readonly ClientRepository $clientRepository,
private readonly AccountFilterBuilder $accountFilterUser
) {
parent::__construct($application);
@@ -108,12 +108,12 @@ final class Client extends Service implements ClientServiceInterface
/**
* @param int $id
*
* @return ClientServiceInterface
* @return ClientService
* @throws ConstraintException
* @throws NoSuchItemException
* @throws QueryException
*/
public function delete(int $id): ClientServiceInterface
public function delete(int $id): ClientService
{
if ($this->clientRepository->delete($id)->getAffectedNumRows() === 0) {
throw new NoSuchItemException(__u('Client not found'), SPException::INFO);

View File

@@ -38,7 +38,7 @@ use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Account\Ports\AccountToTagService;
use SP\Domain\Category\Models\Category;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigDataInterface;
@@ -62,9 +62,9 @@ defined('APP_ROOT') || die();
final class XmlExportService extends Service implements XmlExportServiceInterface
{
private ConfigDataInterface $configData;
private PhpExtensionChecker $extensionChecker;
private ClientServiceInterface $clientService;
private AccountService $accountService;
private PhpExtensionChecker $extensionChecker;
private ClientService $clientService;
private AccountService $accountService;
private AccountToTagService $accountToTagService;
private CategoryService $categoryService;
private TagServiceInterface $tagService;
@@ -76,13 +76,13 @@ final class XmlExportService extends Service implements XmlExportServiceInterfac
private ?string $exportFile = null;
public function __construct(
Application $application,
PhpExtensionChecker $extensionChecker,
ClientServiceInterface $clientService,
AccountService $accountService,
AccountToTagService $accountToTagService,
CategoryService $categoryService,
TagServiceInterface $tagService
Application $application,
PhpExtensionChecker $extensionChecker,
ClientService $clientService,
AccountService $accountService,
AccountToTagService $accountToTagService,
CategoryService $categoryService,
TagServiceInterface $tagService
) {
parent::__construct($application);

View File

@@ -27,7 +27,7 @@ namespace SP\Domain\Import\Services;
use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Tag\Ports\TagServiceInterface;
/**
@@ -36,15 +36,15 @@ use SP\Domain\Tag\Ports\TagServiceInterface;
final class ImportHelper
{
private AccountService $accountService;
private CategoryService $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
private CategoryService $categoryService;
private ClientService $clientService;
private TagServiceInterface $tagService;
public function __construct(
AccountService $accountService,
CategoryService $categoryService,
ClientServiceInterface $clientService,
TagServiceInterface $tagService
AccountService $accountService,
CategoryService $categoryService,
ClientService $clientService,
TagServiceInterface $tagService
) {
$this->accountService = $accountService;
$this->categoryService = $categoryService;
@@ -62,7 +62,7 @@ final class ImportHelper
return $this->categoryService;
}
public function getClientService(): ClientServiceInterface
public function getClientService(): ClientService
{
return $this->clientService;
}

View File

@@ -32,7 +32,7 @@ use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Models\Category;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\NoSuchPropertyException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -55,9 +55,9 @@ trait ImportTrait
protected int $counter = 0;
protected ImportParams $importParams;
private AccountService $accountService;
private CategoryService $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
private CategoryService $categoryService;
private ClientService $clientService;
private TagServiceInterface $tagService;
private array $items;
/**

View File

@@ -26,8 +26,8 @@ namespace SP\Infrastructure\Client\Repositories;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Client\Ports\ClientRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -42,9 +42,9 @@ use function SP\__u;
/**
* Class ClientRepository
*
* @template T of Client
* @template T of ClientModel
*/
final class ClientRepository extends Repository implements ClientRepositoryInterface
final class Client extends Repository implements ClientRepository
{
use RepositoryItemTrait;
@@ -53,13 +53,13 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Creates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return QueryResult
* @throws DuplicatedItemException
* @throws SPException
*/
public function create(Client $client): QueryResult
public function create(ClientModel $client): QueryResult
{
if ($this->checkDuplicatedOnAdd($client)) {
throw new DuplicatedItemException(__u('Duplicated client'));
@@ -79,12 +79,12 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Checks whether the item is duplicated on adding
*
* @param Client $client
* @param ClientModel $client
* @return bool
* @throws ConstraintException
* @throws QueryException
*/
private function checkDuplicatedOnAdd(Client $client): bool
private function checkDuplicatedOnAdd(ClientModel $client): bool
{
$query = $this->queryFactory
->newSelect()
@@ -105,14 +105,14 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Updates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return int
* @throws ConstraintException
* @throws QueryException
* @throws DuplicatedItemException
*/
public function update(Client $client): int
public function update(ClientModel $client): int
{
if ($this->checkDuplicatedOnUpdate($client)) {
throw new DuplicatedItemException(__u('Duplicated client'));
@@ -139,13 +139,13 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Checks whether the item is duplicated on updating
*
* @param Client $client
* @param ClientModel $client
*
* @return bool
* @throws ConstraintException
* @throws QueryException
*/
private function checkDuplicatedOnUpdate(Client $client): bool
private function checkDuplicatedOnUpdate(ClientModel $client): bool
{
$query = $this->queryFactory
->newSelect()
@@ -176,12 +176,12 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols())
->cols(ClientModel::getCols())
->where('id = :id')
->bindValues(['id' => $clientId])
->limit(1);
$queryData = QueryData::buildWithMapper($query, Client::class);
$queryData = QueryData::buildWithMapper($query, ClientModel::class);
return $this->db->doSelect($queryData);
}
@@ -198,12 +198,12 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols())
->cols(ClientModel::getCols())
->where('(name = :name OR hash = :hash)')
->bindValues(['name' => $name, 'hash' => $this->makeItemHash($name)])
->limit(1);
$queryData = QueryData::buildWithMapper($query, Client::class);
$queryData = QueryData::buildWithMapper($query, ClientModel::class);
return $this->db->doSelect($queryData);
}
@@ -218,9 +218,9 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols());
->cols(ClientModel::getCols());
return $this->db->doSelect(QueryData::buildWithMapper($query, Client::class));
return $this->db->doSelect(QueryData::buildWithMapper($query, ClientModel::class));
}
/**
@@ -282,7 +282,7 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols(['hash']))
->cols(ClientModel::getCols(['hash']))
->orderBy(['name'])
->limit($itemSearchData->getLimitCount())
->offset($itemSearchData->getLimitStart());
@@ -295,7 +295,7 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query->bindValues(['name' => $search, 'description' => $search]);
}
$queryData = QueryData::build($query)->setMapClassName(Client::class);
$queryData = QueryData::build($query)->setMapClassName(ClientModel::class);
return $this->db->doSelect($queryData, true);
}

View File

@@ -29,7 +29,7 @@ use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Ports\ClientRepository;
use SP\Domain\Client\Services\Client;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -50,9 +50,9 @@ use SPT\UnitaryTestCase;
class ClientTest extends UnitaryTestCase
{
private ClientRepositoryInterface|MockObject $clientRepository;
private Client $clientService;
private AccountFilterBuilder|Stub $accountFilterUser;
private ClientRepository|MockObject $clientRepository;
private Client $client;
private AccountFilterBuilder|Stub $accountFilterUser;
/**
* @throws NoSuchItemException
@@ -72,7 +72,7 @@ class ClientTest extends UnitaryTestCase
->with($id)
->willReturn(new QueryResult([$client]));
$out = $this->clientService->getById($id);
$out = $this->client->getById($id);
$this->assertEquals($client, $out);
}
@@ -96,7 +96,7 @@ class ClientTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Client not found');
$this->clientService->getById($id);
$this->client->getById($id);
}
/**
@@ -111,7 +111,7 @@ class ClientTest extends UnitaryTestCase
->method('search')
->with($itemSearch);
$this->clientService->search($itemSearch);
$this->client->search($itemSearch);
}
/**
@@ -132,7 +132,7 @@ class ClientTest extends UnitaryTestCase
->with($id)
->willReturn($queryResult);
$this->clientService->delete($id);
$this->client->delete($id);
}
/**
@@ -152,7 +152,7 @@ class ClientTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Client not found');
$this->clientService->delete($id);
$this->client->delete($id);
}
/**
@@ -172,7 +172,7 @@ class ClientTest extends UnitaryTestCase
->with($client)
->willReturn($queryResult);
$out = $this->clientService->create($client);
$out = $this->client->create($client);
$this->assertEquals($queryResult->getLastId(), $out);
}
@@ -195,7 +195,7 @@ class ClientTest extends UnitaryTestCase
->with($client)
->willReturn(1);
$this->clientService->update($client);
$this->client->update($client);
}
/**
@@ -216,7 +216,7 @@ class ClientTest extends UnitaryTestCase
->with($name)
->willReturn(new QueryResult([$client]));
$out = $this->clientService->getByName($name);
$out = $this->client->getByName($name);
$this->assertEquals($client, $out);
}
@@ -240,7 +240,7 @@ class ClientTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Client not found');
$this->clientService->getByName($name);
$this->client->getByName($name);
}
/**
@@ -261,7 +261,7 @@ class ClientTest extends UnitaryTestCase
->with($ids)
->willReturn($queryResult);
$this->clientService->deleteByIdBatch($ids);
$this->client->deleteByIdBatch($ids);
}
/**
@@ -284,7 +284,7 @@ class ClientTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while deleting the clients');
$this->clientService->deleteByIdBatch($ids);
$this->client->deleteByIdBatch($ids);
}
/**
@@ -301,7 +301,7 @@ class ClientTest extends UnitaryTestCase
->method('getAll')
->willReturn(new QueryResult([$client]));
$out = $this->clientService->getAll();
$out = $this->client->getAll();
$this->assertEquals([$client], $out);
}
@@ -321,7 +321,7 @@ class ClientTest extends UnitaryTestCase
->with($this->accountFilterUser)
->willReturn(new QueryResult([$client]));
$out = $this->clientService->getAllForUser();
$out = $this->client->getAllForUser();
$this->assertEquals([$client], $out);
}
@@ -330,7 +330,7 @@ class ClientTest extends UnitaryTestCase
{
parent::setUp();
$this->clientRepository = $this->createMock(ClientRepositoryInterface::class);
$this->clientRepository = $this->createMock(ClientRepository::class);
$select = (new QueryFactory('mysql', QueryFactory::COMMON))->newSelect();
@@ -338,6 +338,6 @@ class ClientTest extends UnitaryTestCase
$this->accountFilterUser->method('buildFilter')
->willReturn($select);
$this->clientService = new Client($this->application, $this->clientRepository, $this->accountFilterUser);
$this->client = new Client($this->application, $this->clientRepository, $this->accountFilterUser);
}
}

View File

@@ -34,12 +34,12 @@ use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Infrastructure\Client\Repositories\ClientRepository;
use SP\Infrastructure\Client\Repositories\Client;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
@@ -52,10 +52,10 @@ use SPT\UnitaryTestCase;
*
* @group unitary
*/
class ClientRepositoryTest extends UnitaryTestCase
class ClientTest extends UnitaryTestCase
{
private ClientRepository $clientRepository;
private Client $client;
private DatabaseInterface|MockObject $database;
/**
@@ -102,7 +102,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->with(...self::withConsecutive([$callbackDuplicate], [$callbackCreate]))
->willReturn(new QueryResult([]), new QueryResult([1]));
$this->clientRepository->create($client);
$this->client->create($client);
}
/**
@@ -135,7 +135,7 @@ class ClientRepositoryTest extends UnitaryTestCase
$this->expectException(DuplicatedItemException::class);
$this->expectExceptionMessage('Duplicated client');
$this->clientRepository->create($client);
$this->client->create($client);
}
/**
@@ -158,7 +158,7 @@ class ClientRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
$this->clientRepository->delete($id);
$this->client->delete($id);
}
/**
@@ -189,7 +189,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with($callback);
$this->clientRepository->deleteByIdBatch($ids);
$this->client->deleteByIdBatch($ids);
}
/**
@@ -202,7 +202,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->expects(self::never())
->method('doQuery');
$this->clientRepository->deleteByIdBatch([]);
$this->client->deleteByIdBatch([]);
}
public function testGetById()
@@ -216,7 +216,7 @@ class ClientRepositoryTest extends UnitaryTestCase
return count($params) === 1
&& $params['id'] === $id
&& $arg->getMapClassName() === Client::class
&& $arg->getMapClassName() === ClientModel::class
&& is_a($query, SelectInterface::class)
&& !empty($query->getStatement());
}
@@ -227,7 +227,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('doSelect')
->with($callback);
$this->clientRepository->getById($id);
$this->client->getById($id);
}
/**
@@ -246,7 +246,7 @@ class ClientRepositoryTest extends UnitaryTestCase
return count($params) === 2
&& $params['name'] === $searchStringLike
&& $params['description'] === $searchStringLike
&& $arg->getMapClassName() === Client::class
&& $arg->getMapClassName() === ClientModel::class
&& is_a($query, SelectInterface::class)
&& !empty($query->getStatement());
}
@@ -257,7 +257,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('doSelect')
->with($callback, true);
$this->clientRepository->search($item);
$this->client->search($item);
}
/**
@@ -269,7 +269,7 @@ class ClientRepositoryTest extends UnitaryTestCase
static function (QueryData $arg) {
$query = $arg->getQuery();
return count($query->getBindValues()) === 0
&& $arg->getMapClassName() === Client::class
&& $arg->getMapClassName() === ClientModel::class
&& is_a($query, SelectInterface::class)
&& !empty($query->getStatement());
}
@@ -280,7 +280,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('doSelect')
->with($callback, true);
$this->clientRepository->search(new ItemSearchData());
$this->client->search(new ItemSearchData());
}
public function testGetAll()
@@ -288,7 +288,7 @@ class ClientRepositoryTest extends UnitaryTestCase
$callback = new Callback(
static function (QueryData $arg) {
$query = $arg->getQuery();
return $arg->getMapClassName() === Client::class
return $arg->getMapClassName() === ClientModel::class
&& is_a($query, SelectInterface::class)
&& !empty($query->getStatement());
}
@@ -299,7 +299,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('doSelect')
->with($callback);
$this->clientRepository->getAll();
$this->client->getAll();
}
/**
@@ -328,7 +328,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('buildFilter')
->willReturn($select);
$this->clientRepository->getAllForFilter($accountFilterUser);
$this->client->getAllForFilter($accountFilterUser);
}
/**
@@ -376,7 +376,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
->willReturn(new QueryResult([]), new QueryResult([1]));
$this->clientRepository->update($client);
$this->client->update($client);
}
/**
@@ -410,7 +410,7 @@ class ClientRepositoryTest extends UnitaryTestCase
$this->expectException(DuplicatedItemException::class);
$this->expectExceptionMessage('Duplicated client');
$this->clientRepository->update($client);
$this->client->update($client);
}
public function testGetByName()
@@ -425,7 +425,7 @@ class ClientRepositoryTest extends UnitaryTestCase
return count($params) === 2
&& $params['name'] === $name
&& !empty($params['hash'])
&& $arg->getMapClassName() === Client::class
&& $arg->getMapClassName() === ClientModel::class
&& is_a($query, SelectInterface::class)
&& !empty($query->getStatement());
}
@@ -436,7 +436,7 @@ class ClientRepositoryTest extends UnitaryTestCase
->method('doSelect')
->with($callback);
$this->clientRepository->getByName($name);
$this->client->getByName($name);
}
protected function setUp(): void
@@ -446,7 +446,7 @@ class ClientRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
$this->clientRepository = new ClientRepository(
$this->client = new Client(
$this->database,
$this->context,
$this->application->getEventDispatcher(),