8000 [Console] Fix horizontal table top border is incorrectly rendered · symfony/symfony@6ef10c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ef10c1

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Console] Fix horizontal table top border is incorrectly rendered
1 parent fbd3a63 commit 6ef10c1

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
@@ -1997,4 +1997,63 @@ public function testWithHyperlinkAndMaxWidth()
19971997

19981998
$this->assertSame($expected, $this->getOutputContent($output));
19991999
}
2000+
2001+
public function testGithubIssue52101HorizontalTrue()
2002+
{
2003+
$tableStyle = (new TableStyle())
2004+
->setHorizontalBorderChars('')
2005+
->setVerticalBorderChars('')
2006+
->setCrossingChars('', '', '', '', '', '', '', '', '')
2007+
;
2008+
2009+
$table = (new Table($output = $this->getOutputStream()))
2010+
->setStyle($tableStyle)
2011+
->setHeaderTitle('Title')
2012+
->setHeaders(['Hello', 'World'])
2013+
->setRows([[1, 2], [3, 4]])
2014+
->setHorizontal(true)
2015+
;
2016+
$table->render();
2017+
2018+
$this->assertSame(<<<TABLE
2019+
┌──── Title ┬───┐
2020+
│ Hello │ 1 │ 3 │
2021+
│ World │ 2 │ 4 │
2022+
└───────┴───┴───┘
2023+
2024+
TABLE
2025+
,
2026+
$this->getOutputContent($output)
2027+
);
2028+
}
2029+
2030+
public function testGithubIssue52101HorizontalFalse()
2031+
{
2032+
$tableStyle = (new TableStyle())
2033+
->setHorizontalBorderChars('')
2034+
->setVerticalBorderChars('')
2035+
->setCrossingChars('', '', '', '', '', '', '', '', '')
2036+
;
2037+
2038+
$table = (new Table($output = $this->getOutputStream()))
2039+
->setStyle($tableStyle)
2040+
->setHeaderTitle('Title')
2041+
->setHeaders(['Hello', 'World'])
2042+
->setRows([[1, 2], [3, 4]])
2043+
->setHorizontal(false)
2044+
;
2045+
$table->render();
2046+
2047+
$this->assertSame(<<<TABLE
2048+
┌──── Title ────┐
2049+
│ Hello │ World │
2050+
├───────┼───────┤
2051+
│ 1 │ 2 │
2052+
│ 3 │ 4 │
2053+
└───────┴───────┘
2054+
2055+
TABLE,
2056+
$this->getOutputContent($output)
2057+
);
2058+
}
20002059
}

0 commit comments

Comments
 (0)
0