File tree 2 files changed +29
-6
lines changed
src/Symfony/Component/Console
2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -374,6 +374,7 @@ public function render()
374
374
375
375
$ isHeader = !$ this ->horizontal ;
376
376
$ isFirstRow = $ this ->horizontal ;
377
+ $ hasTitle = (bool ) $ this ->headerTitle ;
377
378
foreach ($ rows as $ row ) {
378
379
if ($ divider === $ row ) {
379
380
$ isHeader = false ;
@@ -391,12 +392,13 @@ public function render()
391
392
}
392
393
393
394
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 ;
400
402
}
401
403
if ($ this ->horizontal ) {
402
404
$ 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()
1115
1115
];
1116
1116
}
1117
1117
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
+
1118
1139
public function testColumnMaxWidths ()
1119
1140
{
1120
1141
$ table = new Table ($ output = $ this ->getOutputStream ());
<
2EF7
rect height="11.9298746" rx="2" width="53.3333333" x="127.017544" y="48.0703769">
You can’t perform that action at this time.
0 commit comments