diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 904c04b682..289d1a11da 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -518,7 +518,7 @@ class Table foreach ($row as $i => $cell) { if ($cell instanceof TableCell) { - $textLength = strlen($cell); + $textLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell); if ($textLength > 0) { $contentColumns = str_split($cell, ceil($textLength / $cell->getColspan())); foreach ($contentColumns as $position => $content) { diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index a691405c6b..583777b3ca 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -35,9 +35,9 @@ class TableTest extends \PHPUnit_Framework_TestCase /** * @dataProvider testRenderProvider */ - public function testRender($headers, $rows, $style, $expected) + public function testRender($headers, $rows, $style, $expected, $decorated = false) { - $table = new Table($output = $this->getOutputStream()); + $table = new Table($output = $this->getOutputStream($decorated)); $table ->setHeaders($headers) ->setRows($rows) @@ -51,9 +51,9 @@ class TableTest extends \PHPUnit_Framework_TestCase /** * @dataProvider testRenderProvider */ - public function testRenderAddRows($headers, $rows, $style, $expected) + public function testRenderAddRows($headers, $rows, $style, $expected, $decorated = false) { - $table = new Table($output = $this->getOutputStream()); + $table = new Table($output = $this->getOutputStream($decorated)); $table ->setHeaders($headers) ->addRows($rows) @@ -67,9 +67,9 @@ class TableTest extends \PHPUnit_Framework_TestCase /** * @dataProvider testRenderProvider */ - public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected) + public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected, $decorated = false) { - $table = new Table($output = $this->getOutputStream()); + $table = new Table($output = $this->getOutputStream($decorated)); $table ->setHeaders($headers) ->setStyle($style) @@ -485,6 +485,35 @@ TABLE TABLE ), + 'Coslpan and table cells with comment style' => array( + array( + new TableCell('Long Title', array('colspan' => 3)), + ), + array( + array( + new TableCell('9971-5-0210-0', array('colspan' => 3)), + ), + new TableSeparator(), + array( + 'Dante Alighieri', + 'J. R. R. Tolkien', + 'J. R. R', + ), + ), + 'default', + <<stream, StreamOutput::VERBOSITY_NORMAL, false); + return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, $decorated); } protected function getOutputContent(StreamOutput $output)