From a554148b72ec2a2d1f5deb316b9fa7b16751999e Mon Sep 17 00:00:00 2001 From: Ivan Moroz Date: Fri, 29 May 2026 00:09:30 +0300 Subject: [PATCH] CONV-040: Create options schema field structure Co-Authored-By: Claude Opus 4.7 --- .../Converters/DTO/OptionsSchemaField.php | 29 ++++++++++++ .../Converters/OptionsSchemaFieldTest.php | 44 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 app/Support/Converters/DTO/OptionsSchemaField.php create mode 100644 tests/Unit/Converters/OptionsSchemaFieldTest.php diff --git a/app/Support/Converters/DTO/OptionsSchemaField.php b/app/Support/Converters/DTO/OptionsSchemaField.php new file mode 100644 index 0000000..36062d3 --- /dev/null +++ b/app/Support/Converters/DTO/OptionsSchemaField.php @@ -0,0 +1,29 @@ + $this->key, + 'type' => $this->type, + 'label' => $this->label, + 'default' => $this->default, + 'options' => $this->options, + 'required' => $this->required, + 'help' => $this->help, + ]; + } +} diff --git a/tests/Unit/Converters/OptionsSchemaFieldTest.php b/tests/Unit/Converters/OptionsSchemaFieldTest.php new file mode 100644 index 0000000..5a80a70 --- /dev/null +++ b/tests/Unit/Converters/OptionsSchemaFieldTest.php @@ -0,0 +1,44 @@ + 'medium', 'label' => 'Medium'], + ['value' => 'high', 'label' => 'High'], + ], + required: false, + ); + + expect($field->key)->toBe('quality'); + expect($field->type)->toBe('segmented'); + expect($field->label)->toBe('Quality'); + expect($field->default)->toBe('high'); + expect($field->options)->toHaveCount(2); + expect($field->required)->toBeFalse(); +}); + +it('exposes toArray representation', function () { + $field = new OptionsSchemaField( + key: 'remove_metadata', + type: 'toggle', + label: 'Remove metadata', + default: false, + help: 'Strips EXIF data', + ); + + expect($field->toArray())->toBe([ + 'key' => 'remove_metadata', + 'type' => 'toggle', + 'label' => 'Remove metadata', + 'default' => false, + 'options' => [], + 'required' => false, + 'help' => 'Strips EXIF data', + ]); +});