@@ -1017,15 +1017,16 @@ public function testColumnStyle()
10171017
10181018 public function testThrowsWhenTheCellInAnArray ()
10191019 {
1020- $ this ->expectException (InvalidArgumentException::class);
1021- $ this ->expectExceptionMessage ('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given. ' );
1022- $ table = new Table ($ output = $ this ->getOutputStream ());
1020+ $ table = new Table ($ this ->getOutputStream ());
10231021 $ table
10241022 ->setHeaders (['ISBN ' , 'Title ' , 'Author ' , 'Price ' ])
10251023 ->setRows ([
10261024 ['99921-58-10-7 ' , [], 'Dante Alighieri ' , '9.95 ' ],
10271025 ]);
10281026
1027+ $ this ->expectException (InvalidArgumentException::class);
1028+ $ this ->expectExceptionMessage ('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given. ' );
1029+
10291030 $ table ->render ();
10301031 }
10311032
@@ -1997,4 +1998,63 @@ public function testWithHyperlinkAndMaxWidth()
19971998
19981999 $ this ->assertSame ($ expected , $ this ->getOutputContent ($ output ));
19992000 }
2001+
2002+ public function testGithubIssue52101HorizontalTrue ()
2003+ {
2004+ $ tableStyle = (new TableStyle ())
2005+ ->setHorizontalBorderChars ('─ ' )
2006+ ->setVerticalBorderChars ('│ ' )
2007+ ->setCrossingChars ('┼ ' , '┌ ' , '┬ ' , '┐ ' , '┤ ' , '┘ ' , '┴ ' , '└ ' , '├ ' )
2008+ ;
2009+
2010+ $ table = (new Table ($ output = $ this ->getOutputStream ()))
2011+ ->setStyle ($ tableStyle )
2012+ ->setHeaderTitle ('Title ' )
2013+ ->setHeaders (['Hello ' , 'World ' ])
2014+ ->setRows ([[1 , 2 ], [3 , 4 ]])
2015+ ->setHorizontal (true )
2016+ ;
2017+ $ table ->render ();
2018+
2019+ $ this ->assertSame (<<<TABLE
2020+ ┌──── Title ┬───┐
2021+ │ Hello │ 1 │ 3 │
2022+ │ World │ 2 │ 4 │
2023+ └───────┴───┴───┘
2024+
2025+ TABLE
2026+ ,
2027+ $ this ->getOutputContent ($ output )
2028+ );
2029+ }
2030+
2031+ public function testGithubIssue52101HorizontalFalse ()
2032+ {
2033+ $ tableStyle = (new TableStyle ())
2034+ ->setHorizontalBorderChars ('─ ' )
2035+ ->setVerticalBorderChars ('│ ' )
2036+ ->setCrossingChars ('┼ ' , '┌ ' , '┬ ' , '┐ ' , '┤ ' , '┘ ' , '┴ ' , '└ ' , '├ ' )
2037+ ;
2038+
2039+ $ table = (new Table ($ output = $ this ->getOutputStream ()))
2040+ ->setStyle ($ tableStyle )
2041+ ->setHeaderTitle ('Title ' )
2042+ ->setHeaders (['Hello ' , 'World ' ])
2043+ ->setRows ([[1 , 2 ], [3 , 4 ]])
2044+ ->setHorizontal (false )
2045+ ;
2046+ $ table ->render ();
2047+
2048+ $ this ->assertSame (<<<TABLE
2049+ ┌──── Title ────┐
2050+ │ Hello │ World │
2051+ ├───────┼───────┤
2052+ │ 1 │ 2 │
2053+ │ 3 │ 4 │
2054+ └───────┴───────┘
2055+
2056+ TABLE ,
2057+ $ this ->getOutputContent ($ output )
2058+ );
2059+ }
20002060}
0 commit comments