Casting TableCell value to string.
This commit is contained in:
parent
a35986f657
commit
1e5707fed3
@ -35,6 +35,10 @@ class TableCell
|
|||||||
*/
|
*/
|
||||||
public function __construct($value = '', array $options = array())
|
public function __construct($value = '', array $options = array())
|
||||||
{
|
{
|
||||||
|
if (is_numeric($value) && !is_string($value)) {
|
||||||
|
$value = (string) $value;
|
||||||
|
}
|
||||||
|
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
|
||||||
// check option names
|
// check option names
|
||||||
|
@ -509,6 +509,42 @@ TABLE
|
|||||||
| 1234 |
|
| 1234 |
|
||||||
+------+
|
+------+
|
||||||
|
|
||||||
|
TABLE;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTableCellWithNumericIntValue()
|
||||||
|
{
|
||||||
|
$table = new Table($output = $this->getOutputStream());
|
||||||
|
|
||||||
|
$table->setRows(array(array(new TableCell(12345))));
|
||||||
|
$table->render();
|
||||||
|
|
||||||
|
$expected =
|
||||||
|
<<<'TABLE'
|
||||||
|
+-------+
|
||||||
|
| 12345 |
|
||||||
|
+-------+
|
||||||
|
|
||||||
|
TABLE;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTableCellWithNumericFloatValue()
|
||||||
|
{
|
||||||
|
$table = new Table($output = $this->getOutputStream());
|
||||||
|
|
||||||
|
$table->setRows(array(array(new TableCell(12345.01))));
|
||||||
|
$table->render();
|
||||||
|
|
||||||
|
$expected =
|
||||||
|
<<<'TABLE'
|
||||||
|
+----------+
|
||||||
|
| 12345.01 |
|
||||||
|
+----------+
|
||||||
|
|
||||||
TABLE;
|
TABLE;
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||||
|
Reference in New Issue
Block a user