File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525 ->and ($ b ->addressDetail )->toBe ($ a ->addressDetail );
2626
2727 $ c = C::from (['name ' => '123 ' , 'a ' => enumA::A]);
28- var_dump (serialize ($ c ));
2928 $ c1 = unserialize (serialize ($ c ));
30- var_dump ($ c1 );
3129 expect ($ c1 )->toBeInstanceOf (C::class);
3230});
3331
5048test ('enum ' , function () {
5149 $ c = C::from (['name ' => '123 ' , 'a ' => 'a ' ]);
5250 expect ($ c ->a )->toBe (enumA::A);
51+ $ c = serialize ($ c );
52+ $ c = unserialize ($ c );
53+ expect ($ c ->a )->toBe (enumA::A);
5354
5455});
5556
5657it ('throws exception ' , function () {
5758 C::from (['name ' => '123 ' , 'a ' => 'b ' ]);
5859})->throws (ValueError::class);
5960
61+ test ('construct ' , function () {
62+ $ e = new E ('hello ' );
63+ expect ($ e ->name )->toBe ('hello ' );
64+ $ e = serialize ($ e );
65+ $ e = unserialize ($ e );
66+ expect ($ e )->toBeInstanceOf (E::class);
67+ });
68+
6069#[DataAttribute(toSnakeArray: true )]
6170class A extends Data
6271{
@@ -89,4 +98,15 @@ enum enumA: string
8998class D extends Data
9099{
91100 public string |int $ name ;
101+ }
102+
103+ class E extends Data
104+ {
105+ public string $ name ;
106+
107+ public function __construct (string $ name )
108+ {
109+ $ this ->name = $ name ;
110+ parent ::__construct ();
111+ }
92112}
You can’t perform that action at this time.
0 commit comments