8000 Fixed colspan issues with multiple render() calls by jaytaph · Pull Request #14983 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fixed colspan issues with multiple render() calls #14983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixed colspan issues with multiple render() calls
  • Loading branch information
jaytaph committed Jun 14, 2015
commit 29fb17ec5073949c76680c8d2b7518f546ae1c34
10 changes: 10 additions & 0 deletions src/Symfony/Component/Console/Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class Table
*/
private $rows = array();

/**
* Original table rows.
*
* @var array
*/
private $originalRows = array();

/**
* Column widths cache.
*
Expand Down Expand Up @@ -205,6 +212,8 @@ public function setRow($column, array $row)
public function render()
{
$this->calculateNumberOfColumns();

$this->originalRows = $this->rows;
$this->rows = $this->buildTableRows($this->rows);
$this->headers = $this->buildTableRows($this->headers);

Expand Down Expand Up @@ -567,6 +576,7 @@ private function getCellWidth(array $row, $column)
*/
private function cleanup()
{
$this->rows = $this->originalRows;
$this->columnWidths = array();
$this->numberOfColumns = null;
}
Expand Down
27 changes: 27 additions & 0 deletions src/Symfony/Component/Console/Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,33 @@ public function testRowSeparator()
| Bar3 |
+------+

TABLE;

$this->assertEquals($expected, $this->getOutputContent($output));
}

public function testColspans()
{
$table = new Table($output = $this->getOutputStream());
$table->setRows(array(
array(new TableCell('foo', array('colspan' => 2)))
));
$table->render();
$table->render();
$table->render();

$expected =
<<<TABLE
+---+--+
| foo |
+---+--+
+---+--+
| foo |
+---+--+
+---+--+
| foo |
+---+--+

TABLE;

$this->assertEquals($expected, $this->getOutputContent($output));
Expand Down
0