Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a67ff2a

Browse filesBrowse files
committed
[Console] Fixed boxed table style with colspan
1 parent 76c2de0 commit a67ff2a
Copy full SHA for a67ff2a

File tree

Expand file treeCollapse file tree

2 files changed

+38
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+38
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Table.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ private function calculateColumnsWidth($rows)
570570
$lengths[] = $this->getCellWidth($row, $column);
571571
}
572572

573-
$this->columnWidths[$column] = max($lengths) + \strlen($this->style->getCellRowContentFormat()) - 2;
573+
$this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
574574
}
575575
}
576576

@@ -581,7 +581,7 @@ private function calculateColumnsWidth($rows)
581581
*/
582582
private function getColumnSeparatorWidth()
583583
{
584-
return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
584+
return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
585585
}
586586

587587
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/TableTest.php
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,42 @@ public function testGetStyleDefinition()
745745
Table::getStyleDefinition('absent');
746746
}
747747

748+
public function testBoxedStyleWithColspan()
749+
{
750+
$boxed = new TableStyle();
751+
$boxed
752+
->setHorizontalBorderChar('')
753+
->setVerticalBorderChar('')
754+
->setCrossingChar('')
755+
;
756+
757+
$table = new Table($output = $this->getOutputStream());
758+
$table->setStyle($boxed);
759+
$table
760+
->setHeaders(array('ISBN', 'Title', 'Author'))
761+
->setRows(array(
762+
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
763+
new TableSeparator(),
764+
array(new TableCell('This value spans 3 columns.', array('colspan' => 3))),
765+
))
766+
;
767+
$table->render();
768+
769+
$expected =
770+
<<<TABLE
771+
┼───────────────┼───────────────┼─────────────────┼
772+
│ ISBN │ Title │ Author │
773+
┼───────────────┼───────────────┼─────────────────┼
774+
│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │
775+
┼───────────────┼───────────────┼─────────────────┼
776+
│ This value spans 3 columns. │
777+
┼───────────────┼───────────────┼─────────────────┼
778+
779+
TABLE;
780+
781+
$this->assertSame($expected, $this->getOutputContent($output));
782+
}
783+
748784
protected function getOutputStream($decorated = false)
749785
{
750786
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, $decorated);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.