@@ -54,7 +54,7 @@ public function test_read_rows_csv() : void
5454│ order_id │ uuid │ 0 │ 5 │ - │ - │ - │ - │ - │ - │
5555│ created_at │ datetime │ 0 │ 5 │ 2024-02-23T19:18:53+00:00 │ 2024-06-17T19:24:49+00:00 │ - │ - │ - │ - │
5656│ updated_at │ datetime │ 0 │ 5 │ 2024-02-23T19:18:53+00:00 │ 2024-06-17T19:24:49+00:00 │ - │ - │ - │ - │
57- │ discount │ float │ 2 │ 3 │ 12.45 │ 47.10 │ - │ - │ - │ - │
57+ │ discount │ ? float │ 2 │ 3 │ 12.45 │ 47.10 │ - │ - │ - │ - │
5858│ address │ map<string, string> │ 0 │ 5 │ - │ - │ - │ - │ 4 │ 4 │
5959│ notes │ list<string> │ 0 │ 5 │ - │ - │ - │ - │ 1 │ 5 │
6060│ items │ list<structure{sku: string, quantity: integer, price: float}> │ 0 │ 5 │ - │ - │ - │ - │ 2 │ 4 │
@@ -67,4 +67,49 @@ public function test_read_rows_csv() : void
6767
6868 self ::assertStringContainsString ("Execution Time " , $ tester ->getDisplay ());
6969 }
70+
71+ public function test_read_rows_csv_without_schema () : void
72+ {
73+ $ application = new Application ();
74+ $ application ->add (new FileAnalyzeCommand ());
75+ $ tester = new CommandTester ($ application ->get ('file:analyze ' ));
76+
77+ $ tester ->execute (['input-file ' => __DIR__ . '/Fixtures/orders.csv ' , '--input-file-limit ' => 5 , '--stats-columns ' => true ]);
78+
79+ $ tester ->assertCommandIsSuccessful ();
80+
81+ self ::assertStringContainsString (
82+ <<<'OUTPUT'
83+ Analyzing File
84+ ==============
85+
86+ [INFO] File path: orders.csv
87+ OUTPUT,
88+ $ tester ->getDisplay ()
89+ );
90+
91+ self ::assertStringContainsString (
92+ <<<'OUTPUT'
93+ Columns
94+ -------
95+
96+ ┌────────────┬──────┬───────┬─────────────────┬───────────────────────────┬───────────────────────────┬────────────┬────────────┬────────────────────┬────────────────────┐
97+ │ Name │ Type │ Nulls │ Distinct Values │ Min │ Max │ Min Length │ Max Length │ Min Elements Count │ Max Elements Count │
98+ ├────────────┼──────┼───────┼─────────────────┼───────────────────────────┼───────────────────────────┼────────────┼────────────┼────────────────────┼────────────────────┤
99+ │ order_id │ N/A │ 0 │ 5 │ - │ - │ - │ - │ - │ - │
100+ │ created_at │ N/A │ 0 │ 5 │ 2024-02-23T19:18:53+00:00 │ 2024-06-17T19:24:49+00:00 │ - │ - │ - │ - │
101+ │ updated_at │ N/A │ 0 │ 5 │ 2024-02-23T19:18:53+00:00 │ 2024-06-17T19:24:49+00:00 │ - │ - │ - │ - │
102+ │ discount │ N/A │ 2 │ 3 │ 12.45 │ 47.10 │ - │ - │ - │ - │
103+ │ address │ N/A │ 0 │ 5 │ - │ - │ - │ - │ 4 │ 4 │
104+ │ notes │ N/A │ 0 │ 5 │ - │ - │ - │ - │ 1 │ 5 │
105+ │ items │ N/A │ 0 │ 5 │ - │ - │ - │ - │ 2 │ 4 │
106+ └────────────┴──────┴───────┴─────────────────┴───────────────────────────┴───────────────────────────┴────────────┴────────────┴────────────────────┴────────────────────┘
107+ OUTPUT,
108+ $ tester ->getDisplay ()
109+ );
110+
111+ self ::assertStringContainsString ("Analyzed Rows " , $ tester ->getDisplay ());
112+
113+ self ::assertStringContainsString ("Execution Time " , $ tester ->getDisplay ());
114+ }
70115}
0 commit comments