bug #28548 [Console] Fixed boxed table style with colspan (ro0NL)
This PR was merged into the 2.8 branch.
Discussion
----------
[Console] Fixed boxed table style with colspan
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | yes
| New feature? | no
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #28532
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
Commits
-------
a67ff2a2d6
[Console] Fixed boxed table style with colspan
This commit is contained in:
commit
2c8c6f7736
@ -570,7 +570,7 @@ class Table
|
||||
$lengths[] = $this->getCellWidth($row, $column);
|
||||
}
|
||||
|
||||
$this->columnWidths[$column] = max($lengths) + \strlen($this->style->getCellRowContentFormat()) - 2;
|
||||
$this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -581,7 +581,7 @@ class Table
|
||||
*/
|
||||
private function getColumnSeparatorWidth()
|
||||
{
|
||||
return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
|
||||
return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -745,6 +745,42 @@ TABLE;
|
||||
Table::getStyleDefinition('absent');
|
||||
}
|
||||
|
||||
public function testBoxedStyleWithColspan()
|
||||
{
|
||||
$boxed = new TableStyle();
|
||||
$boxed
|
||||
->setHorizontalBorderChar('─')
|
||||
->setVerticalBorderChar('│')
|
||||
->setCrossingChar('┼')
|
||||
;
|
||||
|
||||
$table = new Table($output = $this->getOutputStream());
|
||||
$table->setStyle($boxed);
|
||||
$table
|
||||
->setHeaders(array('ISBN', 'Title', 'Author'))
|
||||
->setRows(array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
|
||||
new TableSeparator(),
|
||||
array(new TableCell('This value spans 3 columns.', array('colspan' => 3))),
|
||||
))
|
||||
;
|
||||
$table->render();
|
||||
|
||||
$expected =
|
||||
<<<TABLE
|
||||
┼───────────────┼───────────────┼─────────────────┼
|
||||
│ ISBN │ Title │ Author │
|
||||
┼───────────────┼───────────────┼─────────────────┼
|
||||
│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │
|
||||
┼───────────────┼───────────────┼─────────────────┼
|
||||
│ This value spans 3 columns. │
|
||||
┼───────────────┼───────────────┼─────────────────┼
|
||||
|
||||
TABLE;
|
||||
|
||||
$this->assertSame($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
protected function getOutputStream($decorated = false)
|
||||
{
|
||||
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, $decorated);
|
||||
|
Reference in New Issue
Block a user