@@ -1041,6 +1041,55 @@ public function it_merges_config_overrides_for_previously_undefined_keys_when_en
10411041 $ this ->assertEquals (['type ' => 'text ' , 'foo ' => 'bar ' ], $ blueprint ->fields ()->get ('from_partial ' )->config ());
10421042 }
10431043
1044+ #[Test]
1045+ public function it_merges_configs_in_correct_priority_order_when_ensuring_a_referenced_field_with_overrides ()
1046+ {
1047+ FieldsetRepository::shouldReceive ('find ' )->with ('the_partial ' )->andReturn (
1048+ (new Fieldset )->setContents (['fields ' => [
1049+ [
1050+ 'handle ' => 'the_field ' ,
1051+ 'field ' => ['type ' => 'text ' , 'display ' => 'The Field ' ],
1052+ ],
1053+ ]])
1054+ );
1055+
1056+ $ blueprint = (new Blueprint )->setContents (['tabs ' => [
1057+ 'tab_one ' => [
1058+ 'sections ' => [
1059+ [
1060+ 'fields ' => [
1061+ ['handle ' => 'from_partial ' , 'field ' => 'the_partial.the_field ' , 'config ' => ['visibility ' => 'read_only ' , 'validate ' => 'max:543 ' ]],
1062+ ],
1063+ ],
1064+ ],
1065+ ],
1066+ ]]);
1067+
1068+ $ blueprint ->ensureField ('from_partial ' , ['validate ' => 'max:200 ' , 'required ' => true ]);
1069+
1070+ $ this ->assertEquals (['tabs ' => [
1071+ 'tab_one ' => [
1072+ 'sections ' => [
1073+ [
1074+ 'fields ' => [
1075+ ['handle ' => 'from_partial ' , 'field ' => 'the_partial.the_field ' , 'config ' => ['visibility ' => 'read_only ' , 'validate ' => 'max:543 ' , 'required ' => true ]],
1076+ ],
1077+ ],
1078+ ],
1079+ ],
1080+ ]], $ blueprint ->contents ());
1081+
1082+ $ fieldConfig = $ blueprint ->fields ()->get ('from_partial ' )->config ();
1083+
1084+ $ this ->assertEquals (true , $ fieldConfig ['required ' ]);
1085+
1086+ $ this ->assertEquals ('text ' , $ fieldConfig ['type ' ]);
1087+ $ this ->assertEquals ('The Field ' , $ fieldConfig ['display ' ]);
1088+
1089+ $ this ->assertEquals ('max:543 ' , $ fieldConfig ['validate ' ]);
1090+ $ this ->assertEquals ('read_only ' , $ fieldConfig ['visibility ' ]);
1091+ }
1092+
10441093 #[Test]
10451094 public function it_merges_undefined_config_overrides_when_ensuring_a_field_that_already_exists_inside_an_imported_fieldset ()
10461095 {
0 commit comments