Files
crewli/api/tests/Unit/Enums/FormBuilder/FormPurposeTest.php
bert.hausmans 135bdb352c feat(forms): add PHP enums for form builder
9 backed string enums covering purpose, field type, submission status/mode/review,
field width, value storage hint, snapshot mode, webhook delivery status.
FormPurpose/FormFieldType include helper methods per ARCH §3/§5. All with
declare(strict_types=1) and values() helpers for validation rules.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 11:27:01 +02:00

102 lines
4.8 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Enums\FormBuilder;
use App\Enums\FormBuilder\FormPurpose;
use App\Enums\FormBuilder\FormSubmissionMode;
use PHPUnit\Framework\TestCase;
class FormPurposeTest extends TestCase
{
public function test_has_22_cases(): void
{
$this->assertCount(22, FormPurpose::cases());
}
public function test_values_contains_expected_strings(): void
{
$values = FormPurpose::values();
$expected = [
'event_registration', 'user_profile', 'artist_profile', 'company_profile',
'artist_advance', 'supplier_intake', 'incident_report', 'feedback',
'post_event_evaluation', 'signature_contract', 'signature_code_of_conduct',
'signature_receipt', 'absence_report', 'check_out_inventory',
'public_complaint', 'public_press_request', 'public_rsvp',
'onboarding_wizard', 'event_setup_wizard', 'company_custom',
'artist_custom', 'custom',
];
foreach ($expected as $v) {
$this->assertContains($v, $values);
}
}
public function test_default_subject_type_for_person_purposes(): void
{
$this->assertSame('person', FormPurpose::EVENT_REGISTRATION->defaultSubjectType());
$this->assertSame('person', FormPurpose::POST_EVENT_EVALUATION->defaultSubjectType());
$this->assertSame('person', FormPurpose::SIGNATURE_RECEIPT->defaultSubjectType());
$this->assertSame('person', FormPurpose::ABSENCE_REPORT->defaultSubjectType());
$this->assertSame('person', FormPurpose::CHECK_OUT_INVENTORY->defaultSubjectType());
}
public function test_default_subject_type_for_entity_purposes(): void
{
$this->assertSame('user', FormPurpose::USER_PROFILE->defaultSubjectType());
$this->assertSame('artist', FormPurpose::ARTIST_PROFILE->defaultSubjectType());
$this->assertSame('company', FormPurpose::COMPANY_PROFILE->defaultSubjectType());
$this->assertSame('artist', FormPurpose::ARTIST_ADVANCE->defaultSubjectType());
$this->assertSame('company', FormPurpose::SUPPLIER_INTAKE->defaultSubjectType());
$this->assertSame('organisation', FormPurpose::ONBOARDING_WIZARD->defaultSubjectType());
$this->assertSame('event', FormPurpose::EVENT_SETUP_WIZARD->defaultSubjectType());
}
public function test_default_subject_type_is_null_for_public_and_custom(): void
{
$this->assertNull(FormPurpose::PUBLIC_COMPLAINT->defaultSubjectType());
$this->assertNull(FormPurpose::PUBLIC_PRESS_REQUEST->defaultSubjectType());
$this->assertNull(FormPurpose::PUBLIC_RSVP->defaultSubjectType());
$this->assertNull(FormPurpose::CUSTOM->defaultSubjectType());
}
public function test_default_submission_mode_draft_single(): void
{
$this->assertSame(FormSubmissionMode::DRAFT_SINGLE, FormPurpose::EVENT_REGISTRATION->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::DRAFT_SINGLE, FormPurpose::ARTIST_ADVANCE->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::DRAFT_SINGLE, FormPurpose::SUPPLIER_INTAKE->defaultSubmissionMode());
}
public function test_default_submission_mode_multiple(): void
{
$this->assertSame(FormSubmissionMode::MULTIPLE, FormPurpose::INCIDENT_REPORT->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::MULTIPLE, FormPurpose::FEEDBACK->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::MULTIPLE, FormPurpose::PUBLIC_COMPLAINT->defaultSubmissionMode());
}
public function test_default_submission_mode_single(): void
{
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::USER_PROFILE->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::ARTIST_PROFILE->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::ONBOARDING_WIZARD->defaultSubmissionMode());
$this->assertSame(FormSubmissionMode::SINGLE, FormPurpose::CUSTOM->defaultSubmissionMode());
}
public function test_allows_public_access(): void
{
$this->assertTrue(FormPurpose::PUBLIC_COMPLAINT->allowsPublicAccess());
$this->assertTrue(FormPurpose::PUBLIC_PRESS_REQUEST->allowsPublicAccess());
$this->assertTrue(FormPurpose::PUBLIC_RSVP->allowsPublicAccess());
$this->assertTrue(FormPurpose::ARTIST_ADVANCE->allowsPublicAccess());
$this->assertTrue(FormPurpose::SUPPLIER_INTAKE->allowsPublicAccess());
}
public function test_disallows_public_access(): void
{
$this->assertFalse(FormPurpose::EVENT_REGISTRATION->allowsPublicAccess());
$this->assertFalse(FormPurpose::USER_PROFILE->allowsPublicAccess());
$this->assertFalse(FormPurpose::INCIDENT_REPORT->allowsPublicAccess());
$this->assertFalse(FormPurpose::CUSTOM->allowsPublicAccess());
}
}