@@ -49,6 +49,78 @@ public function test_format_nested_schema() : void
4949 );
5050 }
5151
52+ public function test_format_nested_schema_as_table () : void
53+ {
54+ $ schema = schema (integer_schema ('integer ' , true ), integer_schema ('float ' ), structure_schema ('user ' , type_structure ([
55+ 'name ' => type_string (true ),
56+ 'age ' => type_int (),
57+ 'address ' => type_structure ([
58+ 'street ' => type_string (true ),
59+ 'city ' => type_string (true ),
60+ 'country ' => type_string (true ),
61+ ]),
62+ ])), string_schema ('name ' , nullable: true ), list_schema ('tags ' , type_list (type_string ())), bool_schema ('active ' ), xml_schema ('xml ' ), xml_element_schema ('xml_element ' ), json_schema ('json ' ), uuid_schema ('uuid ' ), datetime_schema ('datetime ' ));
63+
64+ self ::assertSame (
65+ <<<'SCHEMA'
66+ +-------------+-------------+----------+----------+
67+ | name | type | nullable | metadata |
68+ +-------------+-------------+----------+----------+
69+ | integer | integer | true | [] |
70+ | float | integer | false | [] |
71+ | user | structure | false | [] |
72+ | name | string | true | [] |
73+ | tags | list | false | [] |
74+ | active | boolean | false | [] |
75+ | xml | xml | false | [] |
76+ | xml_element | xml_element | false | [] |
77+ | json | json | false | [] |
78+ | uuid | uuid | false | [] |
79+ | datetime | datetime | false | [] |
80+ +-------------+-------------+----------+----------+
81+ 11 rows
82+
83+ SCHEMA,
84+ (new ASCIISchemaFormatter (true , true ))->format ($ schema )
85+ );
86+ }
87+
88+ public function test_format_nested_schema_as_table_without_metadata () : void
89+ {
90+ $ schema = schema (integer_schema ('integer ' , true ), integer_schema ('float ' ), structure_schema ('user ' , type_structure ([
91+ 'name ' => type_string (true ),
92+ 'age ' => type_int (),
93+ 'address ' => type_structure ([
94+ 'street ' => type_string (true ),
95+ 'city ' => type_string (true ),
96+ 'country ' => type_string (true ),
97+ ]),
98+ ])), string_schema ('name ' , nullable: true ), list_schema ('tags ' , type_list (type_string ())), bool_schema ('active ' ), xml_schema ('xml ' ), xml_element_schema ('xml_element ' ), json_schema ('json ' ), uuid_schema ('uuid ' ), datetime_schema ('datetime ' ));
99+
100+ self ::assertSame (
101+ <<<'SCHEMA'
102+ +-------------+-------------+----------+
103+ | name | type | nullable |
104+ +-------------+-------------+----------+
105+ | integer | integer | true |
106+ | float | integer | false |
107+ | user | structure | false |
108+ | name | string | true |
109+ | tags | list | false |
110+ | active | boolean | false |
111+ | xml | xml | false |
112+ | xml_element | xml_element | false |
113+ | json | json | false |
114+ | uuid | uuid | false |
115+ | datetime | datetime | false |
116+ +-------------+-------------+----------+
117+ 11 rows
118+
119+ SCHEMA,
120+ (new ASCIISchemaFormatter (true ))->format ($ schema )
121+ );
122+ }
123+
52124 public function test_format_schema () : void
53125 {
54126 $ schema = schema (string_schema ('name ' , nullable: true ), list_schema ('tags ' , type_list (type_string ())), bool_schema ('active ' ), xml_schema ('xml ' ), map_schema ('map ' , type_map (type_string (), type_string ())), list_schema ('list ' , type_list (type_map (type_string (), type_integer ()))));
0 commit comments