@@ -169,3 +169,85 @@ class Text extends MockField
169169
170170 expect ($ container ->showOnDetail )->toBeFalse ();
171171});
172+
173+ it ('has resolve method signature compatible with Nova Field class ' , function () {
174+ $ reflection = new ReflectionMethod (NovaDependencyContainer::class, 'resolve ' );
175+
176+ // Method should have no return type (matches Nova Field parent class)
177+ expect ($ reflection ->hasReturnType ())->toBeFalse ();
178+
179+ // Method should have two parameters
180+ $ parameters = $ reflection ->getParameters ();
181+ expect ($ parameters )->toHaveCount (2 );
182+
183+ // First parameter: $resource (no type hint)
184+ expect ($ parameters [0 ]->getName ())->toBe ('resource ' );
185+ expect ($ parameters [0 ]->hasType ())->toBeFalse ();
186+
187+ // Second parameter: $attribute (no type hint, has default null)
188+ expect ($ parameters [1 ]->getName ())->toBe ('attribute ' );
189+ expect ($ parameters [1 ]->hasType ())->toBeFalse ();
190+ expect ($ parameters [1 ]->isDefaultValueAvailable ())->toBeTrue ();
191+ expect ($ parameters [1 ]->getDefaultValue ())->toBeNull ();
192+ });
193+
194+ it ('has resolveForDisplay method signature compatible with Nova Field class ' , function () {
195+ $ reflection = new ReflectionMethod (NovaDependencyContainer::class, 'resolveForDisplay ' );
196+
197+ // Method should have no return type (matches Nova Field parent class)
198+ expect ($ reflection ->hasReturnType ())->toBeFalse ();
199+
200+ // Method should have two parameters
201+ $ parameters = $ reflection ->getParameters ();
202+ expect ($ parameters )->toHaveCount (2 );
203+
204+ // First parameter: $resource (no type hint)
205+ expect ($ parameters [0 ]->getName ())->toBe ('resource ' );
206+ expect ($ parameters [0 ]->hasType ())->toBeFalse ();
207+
208+ // Second parameter: $attribute (no type hint, has default null)
209+ expect ($ parameters [1 ]->getName ())->toBe ('attribute ' );
210+ expect ($ parameters [1 ]->hasType ())->toBeFalse ();
211+ expect ($ parameters [1 ]->isDefaultValueAvailable ())->toBeTrue ();
212+ expect ($ parameters [1 ]->getDefaultValue ())->toBeNull ();
213+ });
214+
215+ it ('can call resolve method with various argument types ' , function () {
216+ $ container = NovaDependencyContainer::make ([
217+ Text::make ('Field 1 ' ),
218+ ]);
219+
220+ $ resource = new stdClass ;
221+ $ resource ->field_1 = 'test value ' ;
222+
223+ // Should work with null attribute (default)
224+ $ container ->resolve ($ resource );
225+
226+ // Should work with string attribute
227+ $ container ->resolve ($ resource , 'field_1 ' );
228+
229+ // Should work with null explicitly passed
230+ $ container ->resolve ($ resource , null );
231+
232+ expect (true )->toBeTrue ();
233+ });
234+
235+ it ('can call resolveForDisplay method with various argument types ' , function () {
236+ $ container = NovaDependencyContainer::make ([
237+ Text::make ('Field 1 ' ),
238+ ]);
239+
240+ $ resource = new stdClass ;
241+ $ resource ->field_1 = 'test value ' ;
242+
243+ // Should work with null attribute (default)
244+ $ container ->resolveForDisplay ($ resource );
245+
246+ // Should work with string attribute
247+ $ container ->resolveForDisplay ($ resource , 'field_1 ' );
248+
249+ // Should work with null explicitly passed
250+ $ container ->resolveForDisplay ($ resource , null );
251+
252+ expect (true )->toBeTrue ();
253+ });
0 commit comments