Skip to content

Commit d2c9c9b

Browse files
Merge branch '2.8' into 3.4
* 2.8: [Console] Fixed boxed table style with colspan parse numbers terminated with decimal separator fail reverse transforming invalid RFC 3339 dates
2 parents 2fdbba7 + 5665f9d commit d2c9c9b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Helper/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ private function calculateColumnsWidth(array $rows)
612612
$lengths[] = $this->getCellWidth($row, $column);
613613
}
614614

615-
$this->effectiveColumnWidths[$column] = max($lengths) + \strlen($this->style->getCellRowContentFormat()) - 2;
615+
$this->effectiveColumnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
616616
}
617617
}
618618

@@ -623,7 +623,7 @@ private function calculateColumnsWidth(array $rows)
623623
*/
624624
private function getColumnSeparatorWidth()
625625
{
626-
return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
626+
return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
627627
}
628628

629629
/**

Tests/Helper/TableTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,42 @@ public function testGetStyleDefinition()
824824
Table::getStyleDefinition('absent');
825825
}
826826

827+
public function testBoxedStyleWithColspan()
828+
{
829+
$boxed = new TableStyle();
830+
$boxed
831+
->setHorizontalBorderChar('')
832+
->setVerticalBorderChar('')
833+
->setCrossingChar('')
834+
;
835+
836+
$table = new Table($output = $this->getOutputStream());
837+
$table->setStyle($boxed);
838+
$table
839+
->setHeaders(array('ISBN', 'Title', 'Author'))
840+
->setRows(array(
841+
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
842+
new TableSeparator(),
843+
array(new TableCell('This value spans 3 columns.', array('colspan' => 3))),
844+
))
845+
;
846+
$table->render();
847+
848+
$expected =
849+
<<<TABLE
850+
┼───────────────┼───────────────┼─────────────────┼
851+
│ ISBN │ Title │ Author │
852+
┼───────────────┼───────────────┼─────────────────┼
853+
│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │
854+
┼───────────────┼───────────────┼─────────────────┼
855+
│ This value spans 3 columns. │
856+
┼───────────────┼───────────────┼─────────────────┼
857+
858+
TABLE;
859+
860+
$this->assertSame($expected, $this->getOutputContent($output));
861+
}
862+
827863
protected function getOutputStream($decorated = false)
828864
{
829865
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, $decorated);

0 commit comments

Comments
 (0)