11<?php
22
3+ use Astral \Serialize \Annotations \DataCollection \InputName ;
4+ use Astral \Serialize \Annotations \DataCollection \OutputName ;
35use Astral \Serialize \Serialize ;
46
57beforeAll (function () {
@@ -12,6 +14,9 @@ class NormalizerOne extends Serialize
1214 class NormalizerTwo extends Serialize
1315 {
1416 public string $ name_two ;
17+
18+ #[InputName('id_2 ' )]
19+ #[OutputName('id_2 ' )]
1520 public int $ id_two ;
1621 }
1722
@@ -47,7 +52,7 @@ class NormalizerClass extends Serialize
4752 'name_one ' => 'one name ' ,
4853 'id_one ' => 1
4954 ]);
50-
55+ //
5156
5257});
5358
@@ -62,22 +67,23 @@ class NormalizerClass extends Serialize
6267 $ normalizerTwo ->id_two = 2 ;
6368
6469 $ res = NormalizerClass::from (one: $ normalizerOne , two: $ normalizerTwo , three: $ normalizerOne );
70+
6571 $ resJson = json_encode ($ res );
66- expect ($ resJson )->toBe ('{"code":200,"message":"\u64cd\u4f5c\u6210\u529f","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_two ":2},"three":{"name_one":"one name","id_one":1}}} ' );
72+ expect ($ resJson )->toBe ('{"code":200,"message":"\u64cd\u4f5c\u6210\u529f","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_2 ":2},"three":{"name_one":"one name","id_one":1}}} ' );
6773
6874 $ res ->setMessage ('233 ' );
6975 $ resJson = json_encode ($ res );
70- expect ($ resJson )->toBe ('{"code":200,"message":"233","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_two ":2},"three":{"name_one":"one name","id_one":1}}} ' );
76+ expect ($ resJson )->toBe ('{"code":200,"message":"233","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_2 ":2},"three":{"name_one":"one name","id_one":1}}} ' );
7177
7278 $ res ->setCode (-1 );
7379 $ resJson = json_encode ($ res );
74- expect ($ resJson )->toBe ('{"code":-1,"message":"233","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_two ":2},"three":{"name_one":"one name","id_one":1}}} ' );
80+ expect ($ resJson )->toBe ('{"code":-1,"message":"233","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_2 ":2},"three":{"name_one":"one name","id_one":1}}} ' );
7581
7682 $ resJson = $ res ->withoutResponseToJsonString ();
77- expect ($ resJson )->toBe ('{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_two":2},"three":{"name_one":"one name","id_one":1}} ' );
83+ var_dump ($ resJson );
84+ expect ($ resJson )->toBe ('{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_2":2},"three":{"name_one":"one name","id_one":1}} ' );
7885
7986 $ resJson = $ res ->toJsonString ();
80- expect ($ resJson )->toBe ('{"code":-1,"message":"233","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_two":2},"three":{"name_one":"one name","id_one":1}}} ' );
81-
82- });
87+ expect ($ resJson )->toBe ('{"code":-1,"message":"233","data":{"one":{"name_one":"one name","id_one":1},"two":{"name_two":"two name","id_2":2},"three":{"name_one":"one name","id_one":1}}} ' );
8388
89+ });
0 commit comments