From 6ef10c1f07744ab869cc0fe79fa08bcba67075ef Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 18 Oct 2023 11:13:21 +0200 Subject: [PATCH] [Console] Fix horizontal table top border is incorrectly rendered --- .../Component/Console/Helper/Table.php | 4 +- .../Console/Tests/Helper/TableTest.php | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index cf714873f5b3b..bbe502e3606a5 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/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/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 9cd5dcc5f9286..68af687053d4d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -1997,4 +1997,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) + ); + } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy