@@ -18,6 +18,7 @@ protected function setUp(): void
18
18
$ attributes = [
19
19
'key ' => 'zip_code ' ,
20
20
'type ' => 'text ' ,
21
+ 'required ' => false ,
21
22
'model_class ' => User::class,
22
23
'contextable_id ' => $ this ->account ->id ,
23
24
'contextable_type ' => $ this ->account ->getMorphClass ()
@@ -50,11 +51,13 @@ public function validate_custom_fields_should_work()
50
51
* @test
51
52
* @dataProvider customFieldDataProvider
52
53
*/
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
54
55
{
55
56
$ attributes = [
56
57
'key ' => 'field ' ,
57
58
'type ' => $ type ,
59
+ 'required ' => $ required ,
60
+ 'default_value ' => $ defaultValue ,
58
61
'model_class ' => User::class,
59
62
'contextable_id ' => $ this ->account ->id ,
60
63
'contextable_type ' => $ this ->account ->getMorphClass ()
@@ -80,12 +83,18 @@ public function custom_load_custom_field_values_should_work($type, $value, $expe
80
83
public function customFieldDataProvider (): array
81
84
{
82
85
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 ],
89
98
];
90
99
}
91
100
}
0 commit comments