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); } } }