8000 bug #52132 [Console] Fix horizontal table top border is incorrectly r… · symfony/symfony@7a59ef0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a59ef0

Browse files
bug #52132 [Console] Fix horizontal table top border is incorrectly rendered (OskarStark)
This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [Console] Fix horizontal table top border is incorrectly rendered | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #52101 | License | MIT cc `@alainrinder` Commits ------- 6ef10c1 [Console] Fix horizontal table top border is incorrectly rendered
2 parents b577601 + 6ef10c1 commit 7a59ef0

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public function render()
411411

412412
if ($isHeader && !$isHeaderSeparatorRendered) {
413413
$this->renderRowSeparator(
414-
$isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
414+
self::SEPARATOR_TOP,
415415
$hasTitle ? $this->headerTitle : null,
416416
$hasTitle ? $this->style->getHeaderTitleFormat() : null
417417
);
@@ -421,7 +421,7 @@ public function render()
421421

422422
if ($isFirstRow) {
423423
$this->renderRowSeparator(
424-
$isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
424+
$horizontal ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
425425
$hasTitle ? $this->headerTitle : null,
426426
$hasTitle ? $this->style->getHeaderTitleFormat() : null
427427
);

src/Symfony/Component/Console/Tests/Helper/TableTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,4 +1998,63 @@ public function testWithHyperlinkAndMaxWidth()
19981998

19991999
$this->assertSame($expected, $this->getOutputContent($output));
20002000
}
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+
}
20012060
}

0 commit comments

Comments
 (0)
0