@@ -18,6 +18,7 @@ protected function setUp(): void
1818 $ attributes = [
1919 'key ' => 'zip_code ' ,
2020 'type ' => 'text ' ,
21+ 'required ' => false ,
2122 'model_class ' => User::class,
2223 'contextable_id ' => $ this ->account ->id ,
2324 'contextable_type ' => $ this ->account ->getMorphClass ()
@@ -50,11 +51,13 @@ public function validate_custom_fields_should_work()
5051 * @test
5152 * @dataProvider customFieldDataProvider
5253 */
53- public function custom_load_custom_field_values_should_work ($ type , $ value , $ expected ): void
54+ public function custom_load_custom_field_values_should_work ($ type , $ value , $ expected, $ required , $ defaultValue ): void
5455 {
5556 $ attributes = [
5657 'key ' => 'field ' ,
5758 'type ' => $ type ,
59+ 'required ' => $ required ,
60+ 'default_value ' => $ defaultValue ,
5861 'model_class ' => User::class,
5962 'contextable_id ' => $ this ->account ->id ,
6063 'contextable_type ' => $ this ->account ->getMorphClass ()
@@ -80,12 +83,18 @@ public function custom_load_custom_field_values_should_work($type, $value, $expe
8083 public function customFieldDataProvider (): array
8184 {
8285 return [
83- 'Text field ' => ['text ' , 'Value ' , 'Value ' ],
84- 'Integer field ' => ['integer ' , '42 ' , 42 ],
85- 'Float field ' => ['float ' , '3.14 ' , 3.14 ],
86- 'Datetime field ' => ['datetime ' , '2023-05-16 12:34:56 ' , '2023-05-16 12:34:56 ' ],
87- 'Select field ' => ['select ' , 'Option 1 ' , 'Option 1 ' ],
88- 'Boolean field ' => ['boolean ' , '1 ' , true ],
86+ 'Text field ' => ['text ' , 'Value ' , 'Value ' , true , '' ],
87+ 'Integer field ' => ['integer ' , '42 ' , 42 , true , '' ],
88+ 'Float field ' => ['float ' , '3.14 ' , 3.14 , true , '' ],
89+ 'Datetime field ' => ['datetime ' , '2023-05-16 12:34:56 ' , '2023-05-16 12:34:56 ' , true , '' ],
90+ 'Select field ' => ['select ' , 'Option 1 ' , 'Option 1 ' , true , '' ],
91+ 'Boolean field ' => ['boolean ' , '1 ' , true , true , '' ],
92+ 'Text field nullable ' => ['text ' , null , 'Value ' , false , 'Value ' ],
93+ 'Integer field nullable ' => ['integer ' , null , 42 , false , '42 ' ],
94+ 'Float field nullable ' => ['float ' , null , 3.14 , false , '3.14 ' ],
95+ 'Datetime field nullable ' => ['datetime ' , null , '2023-05-16 12:34:56 ' , false , '2023-05-16 12:34:56 ' ],
96+ 'Select field nullable ' => ['select ' , null , 'Option 1 ' , false , 'Option 1 ' ],
97+ 'Boolean field nullable ' => ['boolean ' , null , true , false , true ],
8998 ];
9099 }
91100}
0 commit comments