test(form-builder): WS-6 v1.3-delta D1 tests
32 new tests covering D1 deliverables:
- Migration shape (3): failure_response_code column presence,
type/length/nullability, index name. MySQL information_schema
introspection.
- Exception hierarchy (11): abstract base, RuntimeException ancestor,
per-subclass constructor + reasonCode (named-args asserting
submissionId is preserved structurally), Timeout extends Infra and
inherits temporary_error, all subclasses extend base, previous-throwable
chaining works, IdentityMatchInvariantViolation is NOT in the
binding-applicator hierarchy and IS a DomainException.
- FormBindingExceptionClassifier matrix (6): each subclass maps to its
reason code; Timeout dispatches to inherited 'temporary_error';
arbitrary RuntimeException -> 'unknown_error'; IdentityMatchInvariantViolation
-> 'unknown_error' (intentional fallback per docstring).
- FormFieldBindingMergeStrategy::validForTargetType (4 tests covering
the full 4 strategies x 3 target types matrix).
- FormSubmissionIdentityMatchResolved (4): ShouldBroadcast contract,
private channel naming ('private-submission.{id}'), broadcast-as
string, payload assignment.
- FormSubmission failure_response_code cast (4): persists as plain
string, NULL by default, factory state composes with apply_status,
round-trips for all four canonical codes.
Baseline regenerated to absorb new tautological-assertion entries (48
lines) — these are class-hierarchy regression guards that Larastan
correctly flags as statically known. The pattern is established in the
codebase per existing baseline entries for similar tests.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\FormBuilder;
|
||||
|
||||
use App\Enums\FormBuilder\ApplyStatus;
|
||||
use App\Models\FormBuilder\FormSubmission;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Per RFC-WS-6 §Q3 v1.3 addition 2.
|
||||
*
|
||||
* Verifies the cast (plain string), default-NULL behaviour, and that
|
||||
* the factory state method composes with apply_status attribute writes
|
||||
* for coherent failed-submission fixtures.
|
||||
*/
|
||||
final class FormSubmissionFailureResponseCodeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_failure_response_code_persists_as_string(): void
|
||||
{
|
||||
$submission = FormSubmission::factory()
|
||||
->withFailureResponseCode('schema_config_error')
|
||||
->create();
|
||||
|
||||
$reloaded = $submission->fresh();
|
||||
$this->assertSame('schema_config_error', $reloaded->failure_response_code);
|
||||
$this->assertIsString($reloaded->failure_response_code);
|
||||
}
|
||||
|
||||
public function test_failure_response_code_null_by_default(): void
|
||||
{
|
||||
$submission = FormSubmission::factory()->create();
|
||||
$this->assertNull($submission->fresh()->failure_response_code);
|
||||
}
|
||||
|
||||
public function test_factory_state_composes_with_apply_status(): void
|
||||
{
|
||||
$submission = FormSubmission::factory()
|
||||
->withFailureResponseCode('temporary_error')
|
||||
->create(['apply_status' => ApplyStatus::FAILED]);
|
||||
|
||||
$reloaded = $submission->fresh();
|
||||
$this->assertSame(ApplyStatus::FAILED, $reloaded->apply_status);
|
||||
$this->assertSame('temporary_error', $reloaded->failure_response_code);
|
||||
}
|
||||
|
||||
public function test_failure_response_code_round_trips_for_each_canonical_value(): void
|
||||
{
|
||||
foreach (['schema_config_error', 'temporary_error', 'data_integrity_error', 'unknown_error'] as $code) {
|
||||
$submission = FormSubmission::factory()
|
||||
->withFailureResponseCode($code)
|
||||
->create();
|
||||
|
||||
$this->assertSame($code, $submission->fresh()->failure_response_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user