File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -19,4 +19,36 @@ protected function dontSeeArtisanOutput($output)
1919 $ actual = trim (Artisan::output ());
2020 $ this ->assertNotEquals ($ expected , $ actual , "Failed asserting that artisan output is not ` {$ expected }`. " );
2121 }
22+
23+ protected function seeArtisanTableOutput (array $ data )
24+ {
25+ $ message = "Failed asserting that artisan table output equals to expected value. " ;
26+ $ this ->assertEquals ($ data , $ this ->parseArtisanTableOutput (Artisan::output ()), $ message );
27+ }
28+
29+ private function parseArtisanTableOutput ($ output )
30+ {
31+ $ parsed = [];
32+
33+ $ headers = [];
34+ $ outputRows = explode ("\n" , trim ($ output ));
35+ foreach ($ outputRows as $ row ) {
36+ if (!str_contains ($ row , '| ' )) {
37+ continue ;
38+ }
39+
40+ $ row = explode ('| ' , $ row );
41+ $ row = array_filter ($ row );
42+ $ row = array_map ('trim ' , $ row );
43+
44+ if (empty ($ headers )) {
45+ $ headers = $ row ;
46+ continue ;
47+ }
48+
49+ $ parsed [] = array_combine ($ headers , $ row );
50+ }
51+
52+ return $ parsed ;
53+ }
2254}
You can’t perform that action at this time.
0 commit comments