Files
crewli/api/tests/Unit/Enums/FormBuilder/FormPurposeTest.php
bert.hausmans 55ba4f24c0 test(form-builder): cover purpose registry and morph-map alignment
- PurposeRegistryTest: all seven purposes load with expected shape;
  `get()` throws PurposeNotFoundException on unknown slug;
  `allSubjectTypes()` returns exactly [artist, company, person, user];
  `publicAccessibleSlugs()` is only `[event_registration]`.
- PurposeSchemaLifecycleTest: data-provider-driven create → publish
  for all seven purposes; negative tests for event_registration (three
  missing bindings) and supplier_intake (company.name missing); partial
  binding test reports only the missing subset.
- CustomPurposeEscapeRemovedTest: column gone, config file gone,
  FormPurpose::CUSTOM gone, store endpoint rejects `'custom'`, resource
  payload omits the field.
- SubjectTypeRegistryConsolidationTest: submission validation accepts
  registry subject types, rejects everything else including the legacy
  `event` alias that used to be allowed.
- MorphMapAlignmentTest: compile-time guard that every
  PurposeRegistry::allSubjectTypes() alias appears in the morph-map and
  in AppServiceProvider::PURPOSE_SUBJECT_FQCN.
- FormPurposeTest rewritten to cover the seven v1.0 cases and the
  registry-delegation helpers (now extends Tests\TestCase for the
  container).
- Public/listener tests swap the removed PUBLIC_RSVP / PUBLIC_COMPLAINT
  / FEEDBACK references for valid v1.0 purposes, preserving their
  negative-path assertions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 14:36:09 +02:00

65 lines
2.7 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Enums\FormBuilder;
use App\Enums\FormBuilder\FormPurpose;
use App\Enums\FormBuilder\FormSubmissionMode;
use Tests\TestCase;
final class FormPurposeTest extends TestCase
{
public function test_has_seven_cases(): void
{
$this->assertCount(7, FormPurpose::cases());
}
public function test_values_match_v1_vocabulary(): void
{
$this->assertSame(
[
'event_registration',
'artist_advance',
'supplier_intake',
'post_event_evaluation',
'incident_report',
'signature_contract',
'user_profile',
],
FormPurpose::values(),
);
}
public function test_default_submission_mode_delegates_to_registry(): void
{
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::EVENT_REGISTRATION->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::DRAFT_SINGLE, FormPurpose::ARTIST_ADVANCE->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::SUPPLIER_INTAKE->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::MULTIPLE, FormPurpose::INCIDENT_REPORT->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::USER_PROFILE->defaultSubmissionMode());
}
public function test_default_subject_type_delegates_to_registry(): void
{
$this->assertSame('person', FormPurpose::EVENT_REGISTRATION->defaultSubjectType());
$this->assertSame('artist', FormPurpose::ARTIST_ADVANCE->defaultSubjectType());
$this->assertSame('company', FormPurpose::SUPPLIER_INTAKE->defaultSubjectType());
$this->assertSame('person', FormPurpose::POST_EVENT_EVALUATION->defaultSubjectType());
$this->assertSame('person', FormPurpose::INCIDENT_REPORT->defaultSubjectType());
$this->assertSame('user', FormPurpose::SIGNATURE_CONTRACT->defaultSubjectType());
$this->assertSame('user', FormPurpose::USER_PROFILE->defaultSubjectType());
}
public function test_only_event_registration_allows_public_access(): void
{
$this->assertTrue(FormPurpose::EVENT_REGISTRATION->allowsPublicAccess());
$this->assertFalse(FormPurpose::ARTIST_ADVANCE->allowsPublicAccess());
$this->assertFalse(FormPurpose::SUPPLIER_INTAKE->allowsPublicAccess());
$this->assertFalse(FormPurpose::POST_EVENT_EVALUATION->allowsPublicAccess());
$this->assertFalse(FormPurpose::INCIDENT_REPORT->allowsPublicAccess());
$this->assertFalse(FormPurpose::SIGNATURE_CONTRACT->allowsPublicAccess());
$this->assertFalse(FormPurpose::USER_PROFILE->allowsPublicAccess());
}
}