diff --git a/Helper/Table.php b/Helper/Table.php index cf714873f..bbe502e36 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -411,7 +411,7 @@ public function render() if ($isHeader && !$isHeaderSeparatorRendered) { $this->renderRowSeparator( - $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, + self::SEPARATOR_TOP, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null ); @@ -421,7 +421,7 @@ public function render() if ($isFirstRow) { $this->renderRowSeparator( - $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, + $horizontal ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null ); diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 4007a7f55..350482a86 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -1998,4 +1998,63 @@ public function testWithHyperlinkAndMaxWidth() $this->assertSame($expected, $this->getOutputContent($output)); } + + public function testGithubIssue52101HorizontalTrue() + { + $tableStyle = (new TableStyle()) + ->setHorizontalBorderChars('─') + ->setVerticalBorderChars('│') + ->setCrossingChars('┼', '┌', '┬', '┐', '┤', '┘', '┴', '└', '├') + ; + + $table = (new Table($output = $this->getOutputStream())) + ->setStyle($tableStyle) + ->setHeaderTitle('Title') + ->setHeaders(['Hello', 'World']) + ->setRows([[1, 2], [3, 4]]) + ->setHorizontal(true) + ; + $table->render(); + + $this->assertSame(<<getOutputContent($output) + ); + } + + public function testGithubIssue52101HorizontalFalse() + { + $tableStyle = (new TableStyle()) + ->setHorizontalBorderChars('─') + ->setVerticalBorderChars('│') + ->setCrossingChars('┼', '┌', '┬', '┐', '┤', '┘', '┴', '└', '├') + ; + + $table = (new Table($output = $this->getOutputStream())) + ->setStyle($tableStyle) + ->setHeaderTitle('Title') + ->setHeaders(['Hello', 'World']) + ->setRows([[1, 2], [3, 4]]) + ->setHorizontal(false) + ; + $table->render(); + + $this->assertSame(<<
getOutputContent($output) + ); + } }