app->make(PurposeRegistry::class); $morphMap = Relation::morphMap(); foreach ($registry->allSubjectTypes() as $alias) { $this->assertArrayHasKey( $alias, $morphMap, "Purpose subject_type '{$alias}' is declared in PurposeRegistry but " ."missing from Relation::morphMap() in AppServiceProvider. " ."Add it to the 'Domain subject types' block." ); } } public function test_domain_subject_types_block_matches_registry_exactly(): void { $registry = $this->app->make(PurposeRegistry::class); $registryAliases = $registry->allSubjectTypes(); // AppServiceProvider::PURPOSE_SUBJECT_FQCN is the single source of // truth for which aliases the domain-subject-types block can emit. // If the registry adds an alias not present in that lookup, boot() // would throw — but we also assert it here for fast feedback. $reflection = new \ReflectionClass(\App\Providers\AppServiceProvider::class); $lookup = $reflection->getConstant('PURPOSE_SUBJECT_FQCN'); $this->assertIsArray($lookup); foreach ($registryAliases as $alias) { $this->assertArrayHasKey( $alias, $lookup, "Purpose subject_type '{$alias}' has no FQCN in " ."AppServiceProvider::PURPOSE_SUBJECT_FQCN. Register it there." ); } } }