@@ -215,6 +215,10 @@ public function __invoke() {}
215215
216216 expect ($ validatedDTO )->toArray ()
217217 ->toBe ($ dataStructure );
218+
219+ $ validatedDTO ->age = 20 ;
220+ expect ($ validatedDTO )->toArray ()
221+ ->toBe ([...$ dataStructure , 'age ' => 20 ]);
218222});
219223
220224it ('validates that the ValidatedDTO can be converted into a JSON string ' , function () {
@@ -223,6 +227,10 @@ public function __invoke() {}
223227
224228 expect ($ validatedDTO )->toJson ()
225229 ->toBe (json_encode ($ dataStructure ));
230+
231+ $ validatedDTO ->age = 20 ;
232+ expect ($ validatedDTO )->toJson ()
233+ ->toBe (json_encode ([...$ dataStructure , 'age ' => 20 ]));
226234});
227235
228236it ('validates that the ValidatedDTO can be converted into a pretty JSON string ' , function () {
@@ -231,6 +239,10 @@ public function __invoke() {}
231239
232240 expect ($ validatedDTO )->toPrettyJson ()
233241 ->toBe (json_encode ($ dataStructure , JSON_PRETTY_PRINT ));
242+
243+ $ validatedDTO ->age = 20 ;
244+ expect ($ validatedDTO )->toPrettyJson ()
245+ ->toBe (json_encode ([...$ dataStructure , 'age ' => 20 ], JSON_PRETTY_PRINT ));
234246});
235247
236248it ('validates that the ValidatedDTO with nested data can be converted into an array ' , function () {
@@ -361,15 +373,22 @@ public function __invoke() {}
361373
362374 $ model = new class () extends Model
363375 {
364- protected $ fillable = ['name ' ];
376+ protected $ fillable = ['name ' , ' age ' ];
365377 };
366378
367- $ model_instance = $ validatedDTO ->toModel ($ model ::class);
379+ $ modelInstance = $ validatedDTO ->toModel ($ model ::class);
368380
369- expect ($ model_instance )
381+ expect ($ modelInstance )
370382 ->toBeInstanceOf (Model::class)
371383 ->toArray ()
372384 ->toBe (['name ' => $ this ->subject_name ]);
385+
386+ $ validatedDTO ->age = 20 ;
387+ $ modelInstance = $ validatedDTO ->toModel ($ model ::class);
388+ expect ($ modelInstance )
389+ ->toBeInstanceOf (Model::class)
390+ ->toArray ()
391+ ->toBe (['name ' => $ this ->subject_name , 'age ' => 20 ]);
373392});
374393
375394it ('maps data before validation ' , function () {
0 commit comments