create(); $schema = FormSchema::factory()->create([ 'organisation_id' => $organisation->id, 'purpose' => FormPurpose::USER_PROFILE->value, 'snapshot_mode' => FormSchemaSnapshotMode::ALWAYS->value, ]); // Two fields: one with binding, one without (Pattern B). $boundField = FormField::factory()->create([ 'form_schema_id' => $schema->id, 'field_type' => FormFieldType::EMAIL->value, 'slug' => 'email', ]); FormFieldBinding::factory()->forField($boundField)->entityOwned('user', 'email')->create(); FormField::factory()->create([ 'form_schema_id' => $schema->id, 'field_type' => FormFieldType::TEXT->value, 'slug' => 'note', ]); $user = User::factory()->create(); $service = $this->app->make(FormSubmissionService::class); $draft = $service->createDraft($schema, $user, $user); /** @var FormSubmission $submitted */ $submitted = $service->submit($draft, $user); $snapshot = $submitted->fresh()->schema_snapshot; $this->assertIsArray($snapshot); foreach ($snapshot['fields'] as $entry) { $this->assertArrayHasKey('bindings', $entry); $this->assertIsArray($entry['bindings']); $this->assertArrayNotHasKey( 'binding', $entry, 'Snapshot field entries must NOT contain the legacy `binding` (singular) key.', ); } } }