has(\MintyPHP\App\Module\ModuleRegistry::class) || !($GLOBALS['minty_app_container'])->has(\MintyPHP\Service\Access\UiAccessService::class)) { $container = require dirname(__DIR__, 3) . '/lib/App/registerContainer.php'; $this->pushAppContainer($container); setAppContainer($container); } } protected function tearDown(): void { $this->restoreAppContainer(); } public function testProviderReturnsAddressBookKey(): void { $provider = new AddressBookLayoutProvider(); $container = new AppContainer(); $session = [ 'available_departments_by_tenant' => [ [ 'tenant' => ['uuid' => 'abc', 'description' => 'Tenant A'], 'departments' => [['id' => 1, 'description' => 'Dept 1']], ], ], ]; $result = $provider->provide($session, $container); self::assertArrayHasKey('addressbook.nav', $result); $ab = $result['addressbook.nav']; self::assertArrayHasKey('url', $ab); self::assertArrayHasKey('activeSearch', $ab); self::assertArrayHasKey('activeTenants', $ab); self::assertArrayHasKey('activeDepartments', $ab); self::assertArrayHasKey('activeRoles', $ab); self::assertArrayHasKey('activeCustomFilters', $ab); self::assertArrayHasKey('peopleGroups', $ab); self::assertCount(1, $ab['peopleGroups']); } public function testProviderReturnsEmptyPeopleGroupsWhenSessionEmpty(): void { $provider = new AddressBookLayoutProvider(); $container = new AppContainer(); $result = $provider->provide([], $container); self::assertArrayHasKey('addressbook.nav', $result); self::assertSame([], $result['addressbook.nav']['peopleGroups']); } public function testProviderIsIncludedInLayoutNavWhenModuleActive(): void { // When the module is active, appBuildLayoutNavContext() should include // addressbook.nav via the provider loop $layoutNav = appBuildLayoutNavContext([], [], []); self::assertArrayHasKey('addressbook.nav', $layoutNav, 'addressbook.nav key must be present in layoutNav when module is active'); } }