forked from fa/breadcrumb-the-shire
refactor: align addressbook module to MintyPHP\Module\AddressBook namespace
Migrates addressbook service classes from core namespace (MintyPHP\Service\AddressBook\*) to proper module namespace (MintyPHP\Module\AddressBook\Service\*), consistent with the bookmarks module pattern. Moved to module: - AddressBookService → modules/addressbook/lib/Module/AddressBook/Service/ - AddressBookServicesFactory → modules/addressbook/lib/Module/AddressBook/Service/ - AddressBookServiceTest → modules/addressbook/tests/Module/AddressBook/Service/ - Pages, templates, CSS, JS all in module directory All module PHP classes now live under MintyPHP\Module\<Name>\*, enforced by ModuleStructureContractTest::testModuleClassesUseModuleNamespace. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Module\AddressBook\Service;
|
||||
|
||||
use MintyPHP\Service\Access\RoleService;
|
||||
use MintyPHP\Module\AddressBook\Service\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
|
||||
{
|
||||
public function testBuildIndexContextBuildsTenantDepartmentMapForGlobalScope(): void
|
||||
{
|
||||
$userAccountService = $this->createMock(UserAccountService::class);
|
||||
$userAssignmentService = $this->createMock(UserAssignmentService::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);
|
||||
|
||||
$scopeGateway
|
||||
->expects($this->once())
|
||||
->method('getUserTenantIds')
|
||||
->with(7)
|
||||
->willReturn([]);
|
||||
$tenantService
|
||||
->expects($this->once())
|
||||
->method('list')
|
||||
->willReturn([
|
||||
['id' => 1, 'uuid' => 'tenant-a', 'description' => 'Tenant A'],
|
||||
['id' => 2, 'uuid' => 'tenant-b', 'description' => 'Tenant B'],
|
||||
]);
|
||||
$scopeGateway
|
||||
->expects($this->exactly(2))
|
||||
->method('isStrict')
|
||||
->willReturn(false);
|
||||
$departmentService
|
||||
->expects($this->once())
|
||||
->method('list')
|
||||
->willReturn([
|
||||
['id' => 10, 'tenant_id' => 1, 'description' => 'Sales'],
|
||||
['id' => 20, 'tenant_id' => 2, 'description' => 'Support'],
|
||||
]);
|
||||
$departmentService
|
||||
->expects($this->never())
|
||||
->method('listByTenantIds');
|
||||
$roleService
|
||||
->expects($this->once())
|
||||
->method('listActive')
|
||||
->willReturn([]);
|
||||
|
||||
$customFieldGateway
|
||||
->expects($this->once())
|
||||
->method('extractCustomFieldFilterSpec')
|
||||
->with([], 7)
|
||||
->willReturn([
|
||||
'definitions' => [],
|
||||
'query' => [],
|
||||
]);
|
||||
$service = new AddressBookService(
|
||||
$userAccountService,
|
||||
$userAssignmentService,
|
||||
$tenantService,
|
||||
$departmentService,
|
||||
$roleService,
|
||||
$scopeGateway,
|
||||
$customFieldGateway,
|
||||
$avatarService
|
||||
);
|
||||
|
||||
$context = $service->buildIndexContext(7, []);
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
'tenant-a' => ['10'],
|
||||
'tenant-b' => ['20'],
|
||||
],
|
||||
$context['tenantDepartmentMap']
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user