Parallel interface to PurposeGuardProvider for runtime subject resolution. Seven concrete resolvers, one per v1.0 purpose. Wired through purposes.php via subject_resolver_class key. EventRegistration uses PersonProvisioner (may create). Other purposes resolve from existing context (portal token, production request, auth). IncidentReport is the only purpose allowed to return null (anonymous- allowed configurations); the others return concrete model types (narrowed via PHP covariance) for caller convenience. Refs: RFC-WS-6.md §3 (Q9) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\FormBuilder\Purposes;
|
|
|
|
use App\FormBuilder\Purposes\PurposeRegistry;
|
|
use App\FormBuilder\Purposes\PurposeSubjectResolver;
|
|
use Tests\TestCase;
|
|
|
|
final class AllPurposesSubjectResolverWiringTest extends TestCase
|
|
{
|
|
public function test_every_purpose_has_a_subject_resolver_class(): void
|
|
{
|
|
/** @var array<string, mixed> $config */
|
|
$config = config('form_builder.purposes');
|
|
$this->assertNotEmpty($config);
|
|
|
|
foreach ($config as $slug => $attrs) {
|
|
$this->assertArrayHasKey(
|
|
'subject_resolver_class',
|
|
$attrs,
|
|
"Purpose '{$slug}' is missing the subject_resolver_class config key.",
|
|
);
|
|
}
|
|
}
|
|
|
|
public function test_registry_resolves_a_subject_resolver_for_every_purpose(): void
|
|
{
|
|
$registry = $this->app->make(PurposeRegistry::class);
|
|
|
|
foreach (array_keys($registry->all()) as $slug) {
|
|
$resolver = $registry->subjectResolverFor($slug);
|
|
$this->assertInstanceOf(PurposeSubjectResolver::class, $resolver);
|
|
}
|
|
}
|
|
}
|