File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,11 @@ public function field(string $handle): ?Field
108108 return $ this ->fields ()->get ($ handle );
109109 }
110110
111+ public function hasField ($ field )
112+ {
113+ return $ this ->fields ()->has ($ field );
114+ }
115+
111116 public function isNamespaced (): bool
112117 {
113118 return Str::contains ($ this ->handle (), ':: ' );
Original file line number Diff line number Diff line change @@ -167,6 +167,32 @@ public function gets_a_single_field()
167167 $ this ->assertNull ($ fieldset ->field ('unknown ' ));
168168 }
169169
170+ #[Test]
171+ public function it_can_check_if_has_field ()
172+ {
173+ FieldsetRepository::shouldReceive ('find ' )
174+ ->with ('partial ' )
175+ ->andReturn ((new Fieldset )->setContents ([
176+ 'fields ' => [
177+ ['handle ' => 'two ' , 'field ' => ['type ' => 'text ' ]],
178+ ],
179+ ]))
180+ ->once ();
181+
182+ $ fieldset = new Fieldset ;
183+
184+ $ fieldset ->setContents ([
185+ 'fields ' => [
186+ ['handle ' => 'one ' , 'field ' => ['type ' => 'text ' ]],
187+ ['import ' => 'partial ' ],
188+ ],
189+ ]);
190+
191+ $ this ->assertTrue ($ fieldset ->hasField ('one ' ));
192+ $ this ->assertTrue ($ fieldset ->hasField ('two ' ));
193+ $ this ->assertFalse ($ fieldset ->hasField ('three ' ));
194+ }
195+
170196 #[Test]
171197 public function gets_blueprints_importing_fieldset ()
172198 {
You can’t perform that action at this time.
0 commit comments