TenantAtlas/apps/platform/tests/Unit/TenantRequiredPermissionsFeatureImpactTest.php
ahmido 292d555eac refactor: consolidate internal tenant model naming (#355)
## Summary
- consolidate internal platform naming from `Tenant` to `Environment` / `ManagedEnvironment` across models, controllers, services, and Filament resources
- rename environment-scoped UI surfaces such as dashboards, chooser flows, navigation, and related widgets to match the updated environment-first domain language
- align middleware, onboarding/review lifecycle services, jobs, and route/context controllers with the new environment-scoped architecture

## Validation
- not rerun as part of this commit/push/PR request

## Notes
- branch is 1 commit ahead of `platform-dev`
- main commit: `refactor: consolidate internal tenant model naming`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #355
2026-05-14 11:13:28 +00:00

68 lines
1.9 KiB
PHP

<?php
use App\Services\Intune\ManagedEnvironmentRequiredPermissionsViewModelBuilder;
it('aggregates feature impacts without double-counting within a feature', function (): void {
$rows = [
[
'key' => 'P1',
'type' => 'application',
'description' => null,
'features' => ['backup'],
'status' => 'missing',
'details' => null,
],
[
'key' => 'P2',
'type' => 'delegated',
'description' => null,
'features' => ['backup'],
'status' => 'missing',
'details' => null,
],
[
'key' => 'P3',
'type' => 'application',
'description' => null,
'features' => ['backup', 'drift'],
'status' => 'granted',
'details' => null,
],
[
'key' => 'P4',
'type' => 'application',
'description' => null,
'features' => ['drift'],
'status' => 'missing',
'details' => null,
],
[
'key' => 'P5',
'type' => 'application',
'description' => null,
'features' => ['backup', 'backup'],
'status' => 'missing',
'details' => null,
],
];
$impacts = ManagedEnvironmentRequiredPermissionsViewModelBuilder::deriveFeatureImpacts($rows);
$byFeature = collect($impacts)->keyBy('feature')->all();
expect($byFeature['backup'])->toMatchArray([
'feature' => 'backup',
'missing' => 3,
'required_application' => 3,
'required_delegated' => 1,
'blocked' => true,
]);
expect($byFeature['drift'])->toMatchArray([
'feature' => 'drift',
'missing' => 1,
'required_application' => 2,
'required_delegated' => 0,
'blocked' => true,
]);
});