File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -374,6 +374,7 @@ public function render()
374374
375375 $ isHeader = !$ this ->horizontal ;
376376 $ isFirstRow = $ this ->horizontal ;
377+ $ hasTitle = (bool ) $ this ->headerTitle ;
377378 foreach ($ rows as $ row ) {
378379 if ($ divider === $ row ) {
379380 $ isHeader = false ;
@@ -391,12 +392,13 @@ public function render()
391392 }
392393
393394 if ($ isHeader || $ isFirstRow ) {
394- if ($ isFirstRow ) {
395- $ this ->renderRowSeparator (self ::SEPARATOR_TOP_BOTTOM );
396- $ isFirstRow = false ;
397- } else {
398- $ this ->renderRowSeparator (self ::SEPARATOR_TOP , $ this ->headerTitle , $ this ->style ->getHeaderTitleFormat ());
399- }
395+ $ this ->renderRowSeparator (
396+ $ isHeader ? self ::SEPARATOR_TOP : self ::SEPARATOR_TOP_BOTTOM ,
397+ $ hasTitle ? $ this ->headerTitle : null ,
398+ $ hasTitle ? $ this ->style ->getHeaderTitleFormat () : null
399+ );
400+ $ isFirstRow = false ;
401+ $ hasTitle = false ;
400402 }
401403 if ($ this ->horizontal ) {
402404 $ this ->renderRow ($ row , $ this ->style ->getCellRowFormat (), $ this ->style ->getCellHeaderFormat ());
Original file line number Diff line number Diff line change @@ -1115,6 +1115,27 @@ public function renderSetTitle()
11151115 ];
11161116 }
11171117
1118+ public function testSetTitleWithoutHeaders ()
1119+ {
1120+ (new Table ($ output = $ this ->getOutputStream ()))
1121+ ->setHeaderTitle ('Reproducer ' )
1122+ ->setRows ([
1123+ ['Value ' , '123-456 ' ],
1124+ ['Some other value ' , '789-0 ' ],
1125+ ])
1126+ ->render ();
1127+
1128+ $ expected = <<<'TABLE'
1129+ +-------- Reproducer --------+
1130+ | Value | 123-456 |
1131+ | Some other value | 789-0 |
1132+ +------------------+---------+
1133+
1134+ TABLE;
1135+
1136+ $ this ->assertSame ($ expected , $ this ->getOutputContent ($ output ));
1137+ }
1138+
11181139 public function testColumnMaxWidths ()
11191140 {
11201141 $ table = new Table ($ output = $ this ->getOutputStream ());
You can’t perform that action at this time.
0 commit comments