refactor(arch): enforce gateway compliance and remove service-wrapping gateways
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace MintyPHP\Tests\Service\AddressBook;
|
||||
|
||||
use MintyPHP\Service\AddressBook\AddressBookAvatarGateway;
|
||||
use MintyPHP\Service\AddressBook\AddressBookCustomFieldGateway;
|
||||
use MintyPHP\Service\AddressBook\AddressBookDirectoryGateway;
|
||||
use MintyPHP\Service\Access\RoleService;
|
||||
use MintyPHP\Service\AddressBook\AddressBookService;
|
||||
use MintyPHP\Service\CustomField\UserCustomFieldValueService;
|
||||
use MintyPHP\Service\Org\DepartmentService;
|
||||
use MintyPHP\Service\Tenant\TenantScopeService;
|
||||
use MintyPHP\Service\Tenant\TenantService;
|
||||
use MintyPHP\Service\User\UserAccountService;
|
||||
use MintyPHP\Service\User\UserAssignmentService;
|
||||
use MintyPHP\Service\User\UserAvatarService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AddressBookServiceTest extends TestCase
|
||||
@@ -16,61 +19,61 @@ class AddressBookServiceTest extends TestCase
|
||||
{
|
||||
$userAccountService = $this->createMock(UserAccountService::class);
|
||||
$userAssignmentService = $this->createMock(UserAssignmentService::class);
|
||||
$directoryGateway = $this->createMock(AddressBookDirectoryGateway::class);
|
||||
$customFieldGateway = $this->createMock(AddressBookCustomFieldGateway::class);
|
||||
$avatarGateway = $this->createMock(AddressBookAvatarGateway::class);
|
||||
$tenantService = $this->createMock(TenantService::class);
|
||||
$departmentService = $this->createMock(DepartmentService::class);
|
||||
$roleService = $this->createMock(RoleService::class);
|
||||
$scopeGateway = $this->createMock(TenantScopeService::class);
|
||||
$customFieldGateway = $this->createMock(UserCustomFieldValueService::class);
|
||||
$avatarService = $this->createMock(UserAvatarService::class);
|
||||
|
||||
$directoryGateway
|
||||
$scopeGateway
|
||||
->expects($this->once())
|
||||
->method('getUserTenantIds')
|
||||
->with(7)
|
||||
->willReturn([]);
|
||||
$directoryGateway
|
||||
$tenantService
|
||||
->expects($this->once())
|
||||
->method('listTenants')
|
||||
->method('list')
|
||||
->willReturn([
|
||||
['id' => 1, 'uuid' => 'tenant-a', 'description' => 'Tenant A'],
|
||||
['id' => 2, 'uuid' => 'tenant-b', 'description' => 'Tenant B'],
|
||||
]);
|
||||
$directoryGateway
|
||||
$scopeGateway
|
||||
->expects($this->exactly(2))
|
||||
->method('isStrictScope')
|
||||
->method('isStrict')
|
||||
->willReturn(false);
|
||||
$directoryGateway
|
||||
$departmentService
|
||||
->expects($this->once())
|
||||
->method('listDepartments')
|
||||
->method('list')
|
||||
->willReturn([
|
||||
['id' => 10, 'tenant_id' => 1, 'description' => 'Sales'],
|
||||
['id' => 20, 'tenant_id' => 2, 'description' => 'Support'],
|
||||
]);
|
||||
$directoryGateway
|
||||
$departmentService
|
||||
->expects($this->never())
|
||||
->method('listDepartmentsByTenantIds');
|
||||
$directoryGateway
|
||||
->method('listByTenantIds');
|
||||
$roleService
|
||||
->expects($this->once())
|
||||
->method('listActiveRoles')
|
||||
->method('listActive')
|
||||
->willReturn([]);
|
||||
|
||||
$customFieldGateway
|
||||
->expects($this->once())
|
||||
->method('extractFilterSpec')
|
||||
->method('extractAddressBookFilterSpec')
|
||||
->with([], 7)
|
||||
->willReturn([
|
||||
'definitions' => [],
|
||||
'query' => [],
|
||||
]);
|
||||
$customFieldGateway
|
||||
->expects($this->once())
|
||||
->method('listOptionsByDefinitionIds')
|
||||
->with([], true)
|
||||
->willReturn([]);
|
||||
|
||||
$service = new AddressBookService(
|
||||
$userAccountService,
|
||||
$userAssignmentService,
|
||||
$directoryGateway,
|
||||
$tenantService,
|
||||
$departmentService,
|
||||
$roleService,
|
||||
$scopeGateway,
|
||||
$customFieldGateway,
|
||||
$avatarGateway
|
||||
$avatarService
|
||||
);
|
||||
|
||||
$context = $service->buildIndexContext(7, []);
|
||||
|
||||
Reference in New Issue
Block a user