@@ -481,4 +481,52 @@ public function testImplementsCorrectInterfaces(): void
481
481
$ config
482
482
);
483
483
}
484
+
485
+ /**
486
+ * Tests setCustomOption method.
487
+ *
488
+ * @return void
489
+ */
490
+ public function testSetCustomOption (): void
491
+ {
492
+ $ config = new ModelConfig ();
493
+
494
+ // Test setting a single custom option
495
+ $ config ->setCustomOption ('key1 ' , 'value1 ' );
496
+ $ customOptions = $ config ->getCustomOptions ();
497
+ $ this ->assertArrayHasKey ('key1 ' , $ customOptions );
498
+ $ this ->assertEquals ('value1 ' , $ customOptions ['key1 ' ]);
499
+
500
+ // Test setting multiple custom options
501
+ $ config ->setCustomOption ('key2 ' , 42 );
502
+ $ config ->setCustomOption ('key3 ' , true );
503
+ $ config ->setCustomOption ('key4 ' , ['nested ' => 'array ' ]);
504
+
505
+ $ customOptions = $ config ->getCustomOptions ();
506
+ $ this ->assertCount (4 , $ customOptions );
507
+ $ this ->assertEquals ('value1 ' , $ customOptions ['key1 ' ]);
508
+ $ this ->assertEquals (42 , $ customOptions ['key2 ' ]);
509
+ $ this ->assertTrue ($ customOptions ['key3 ' ]);
510
+ $ this ->assertEquals (['nested ' => 'array ' ], $ customOptions ['key4 ' ]);
511
+
512
+ // Test overwriting an existing custom option
513
+ $ config ->setCustomOption ('key1 ' , 'new value ' );
514
+ $ customOptions = $ config ->getCustomOptions ();
515
+ $ this ->assertEquals ('new value ' , $ customOptions ['key1 ' ]);
516
+
517
+ // Test that setCustomOption works with null values
518
+ $ config ->setCustomOption ('nullKey ' , null );
519
+ $ customOptions = $ config ->getCustomOptions ();
520
+ $ this ->assertArrayHasKey ('nullKey ' , $ customOptions );
521
+ $ this ->assertNull ($ customOptions ['nullKey ' ]);
522
+
523
+ // Test that custom options are preserved in array conversion
524
+ $ array = $ config ->toArray ();
525
+ $ this ->assertArrayHasKey (ModelConfig::KEY_CUSTOM_OPTIONS , $ array );
526
+ $ this ->assertEquals ($ customOptions , $ array [ModelConfig::KEY_CUSTOM_OPTIONS ]);
527
+
528
+ // Test round-trip with custom options set via setCustomOption
529
+ $ restored = ModelConfig::fromArray ($ array );
530
+ $ this ->assertEquals ($ customOptions , $ restored ->getCustomOptions ());
531
+ }
484
532
}
0 commit comments